[英]“hostname does not match the server certificate” with aws-sdk-ruby when accessing S3 objects
I have created a new S3 bucket on aws. 我在aws上创建了一个新的S3存储桶。 I have a certificate issue I didn't have with the same code on my original bucket.
我有一个证书问题,而原始存储桶中没有相同的代码。
Here is the code : 这是代码:
AWS.config(access_key_id: AWS_ACCESS_KEY_ID, secret_access_key:AWS_SECRET_ACCESS_KEY, region: S3_REGION)
s3 = AWS::S3.new
bucket = s3.buckets[S3_BUCKET_NAME]
@resp = bucket.objects.with_prefix('categories/'+@category.id.to_s+"/")
@resp.each do |item|
end
returns the following error when "@resp.each" is executed: 执行“ @ resp.each”时返回以下错误:
hostname does not match the server certificate (OpenSSL::SSL::SSLError)
Is there something to configurate on AWS S3 to avoid this error? 是否需要在AWS S3上进行配置以避免此错误?
I was having the same issue, and I solved it by doing: 我遇到了同样的问题,并且通过执行以下操作解决了该问题:
Aws::S3::Client.new(
:access_key_id => 'YOUR_ACCESS_KEY_ID',
:secret_access_key => 'YOUR_SECRET_ACCESS_KEY',
:region => 'YOUR_REGION',
:force_path_style => true)
Basically, by specifying also a path style. 基本上,通过指定路径样式。 Let me know if it works!
让我知道它是否有效!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.