简体   繁体   English

Seahorse :: Client :: NetworkingError(主机名“ mybucketname.s3.s3-us-west-2.amazonaws.com”与服务器证书不匹配)

[英]Seahorse::Client::NetworkingError (hostname “mybucketname.s3.s3-us-west-2.amazonaws.com” does not match the server certificate)

I'm having an issue with calling .head_object using Amazon AWS SDK Version 2. I'm working in a Rails project, using Figaro to set my environment variables and have named them as AWS SDK expects: AWS_ACCESS_KEY_ID, etc. 我在使用Amazon AWS开发工具包版本2调用.head_object时遇到问题。我正在Rails项目中工作,使用Figaro设置环境变量并将其命名为AWS开发工具包期望的名称:AWS_ACCESS_KEY_ID,等等。

Here's the code I'm using to try to call head_object: 这是我用来尝试调用head_object的代码:

direct_upload_url_data = %r{\/(?<path>uploads\/.+\/(?<filename>.+))\z}.match(direct_upload_url)
direct_upload_url_data_string = direct_upload_url_data.to_s
s3 = Aws::S3::Client.new
direct_upload_head = s3.head_object(
    bucket: ENV['AWS_BUCKET'],
    key: direct_upload_url_data_string
  )

  self.image_file_name     = direct_upload_url_data[:filename]
  self.image_file_size     = direct_upload_head.content_length
  self.image_content_type  = direct_upload_head.content_type
  self.image_updated_at    = direct_upload_head.last_modified

As you can see I'm trying to access a specific file's metadata. 如您所见,我正在尝试访问特定文件的元数据。 I've checked the regex and it seems to be returning the correct key which is something like "uploads/{uniqueID}/image.jpg" The error is coming on the line where I am trying to call head_object. 我检查了正则表达式,它似乎返回了正确的密钥,类似于“ uploads / {uniqueID} /image.jpg”之类的错误。我试图调用head_object的那一行出现了错误。 The error I'm getting is 我得到的错误是

Seahorse::Client::NetworkingError (hostname "mybucketname.s3.s3-us-west-2.amazonaws.com" does not match the server certificate)

That path is not what I see when I go to my bucket, I see https://s3-us-west-2.amazonaws.com/mybucketname so I'm not sure if that's the reason I'm getting the error. 当我进入存储桶时,该路径不是我看到的,我看到的是https://s3-us-west-2.amazonaws.com/mybucketname,因此我不确定这是否是我得到错误的原因。 I've connected to this bucket before using AWS SDK Version 1 so I know my access and secret keys are working fine. 在使用AWS开发工具包版本1之前,我已连接到此存储桶,因此我知道我的访问和密钥工作正常。 Thanks in advance for your help. 在此先感谢您的帮助。

It seems like you have a wrong region name for your amazon bucket. 您的亚马逊存储桶似乎使用了错误的区域名称。 Try to change "s3-us-west-2" to "us-west-2". 尝试将“ s3-us-west-2”更改为“ us-west-2”。

I'm very sure you've already resolved the issue but for future readers, as tapatun mentioned, make sure your region name does not include the s3 prefix and should read: "us-west-2". 我非常确定您已经解决了该问题,但是对于未来的读者(如tapatun所述),请确保您的区域名称不包含s3前缀,并应显示为:“ us-west-2”。

But afterwards, make sure to restart your server, otherwise the old configurations may still remain making you go on a wild goose chase! 但是之后,请确保重新启动服务器,否则旧的配置可能仍然保留,使您一头雾水!

Good luck and happy coding everyone! 祝大家好运,祝大家编码愉快!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Heroku 主动存储 S3 Seahorse::Client::NetworkingError (Net::OpenTimeout) - Heroku active storage S3 Seahorse::Client::NetworkingError (Net::OpenTimeout) Seahorse :: Client :: NetworkingError使用Rails上传Amazon S3文件 - Seahorse::Client::NetworkingError Amazon S3 file upload with rails Seahorse :: Client :: NetworkingError(getaddrinfo:未知此类主机。),同时使用回形针将图像上传到s3并用于heroku应用程序 - Seahorse::Client::NetworkingError (getaddrinfo: No such host is known. ) while uploading image to s3 using paperclip for heroku app Ruby rails 回形针 Seahorse::Client::NetworkingError(SSL_connect 返回=1 errno=0 状态=错误:证书验证失败) - Ruby rails paperclip Seahorse::Client::NetworkingError (SSL_connect returned=1 errno=0 state=error: certificate verify failed) Amazon S3 - 主机名与服务器证书不匹配 (OpenSSL::SSL::SSLError) + rails - Amazon S3 - hostname does not match the server certificate (OpenSSL::SSL::SSLError) + rails 访问S3对象时,aws-sdk-ruby显示“主机名与服务器证书不匹配” - “hostname does not match the server certificate” with aws-sdk-ruby when accessing S3 objects carrierwave图像上传到s3“主机名与证书错误不匹配” - carrierwave image upload to s3 “hostname does not match certificate error” Errno :: ECONNREFUSED:连接被拒绝-“ bucketname.s3-eu-west-1.amazonaws.com”的connect(2) - Errno::ECONNREFUSED: Connection refused - connect(2) for “bucketname.s3-eu-west-1.amazonaws.com” 自定义域证书错误•服务器的证书(heroku)与URL www.app.com不匹配 - Custom domain certificate error • Server's certificate (heroku) does not match the URL www.app.com OpenSSL::SSL::SSLError:主机名“smtp.gmail.com”与服务器证书不匹配 - OpenSSL::SSL::SSLError: hostname "smtp.gmail.com" does not match the server certificate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM