在Heroku上使用时,宝途无法连接到S3水桶时期在他们的名字,水桶、连接到、时期、名字

由网友(只为你转眸一笑)分享简介:我们得到一个证书错误试图连接到我们使用的Boto S3斗的时候。奇怪的是,在它的名字期间WHILE在Heroku上运行的访问桶,这只能体现。We're getting a certificate error when trying to connect to our S3 bucket using Boto. Str...

我们得到一个证书错误试图连接到我们使用的Boto S3斗的时候。奇怪的是,在它的名字期间WHILE在Heroku上运行的访问桶,这只能体现。

We're getting a certificate error when trying to connect to our S3 bucket using Boto. Strangely, this only manifests itself when accessing a bucket with periods in its name WHILE running on Heroku.

from boto.s3.connection import S3Connection
conn = S3Connection({our_s3_key}, {our_s3_secret})
bucket = conn.get_bucket('ourcompany.images')

引发以下错误:

Raises the following error:

CertificateError:主机名ourcompany.images.s3.amazonaws.com   不匹配的任一'* .s3.amazonaws.com','s3.amazonaws.com'

CertificateError: hostname 'ourcompany.images.s3.amazonaws.com' doesn't match either of '*.s3.amazonaws.com', 's3.amazonaws.com'

但在本地运行时相同的code正常工作,也将工作在Heroku如果桶的名字是'我们公司面试,形象'而不是'ourcompany.images

But the same code works fine when run locally, and would also work on Heroku if the bucket name were 'ourcompany-images' instead of 'ourcompany.images'

推荐答案

按照相关github上的问题,这种添加到配置:

According to the relevant github issue, add this to the configuration:

[s3]
calling_format = boto.s3.connection.OrdinaryCallingFormat

或者指定 calling_format 在实例的S3Connection:

Or, specify the calling_format while instantiating an S3Connection:

from boto.s3.connection import OrdinaryCallingFormat

conn = S3Connection(access_key, secret_key, calling_format=OrdinaryCallingFormat())

在code为你工作在本地和在Heroku上没有工作,因为使用了不同的Python版本中,最有可能的。我怀疑你使用 2.7.9 运行在Heroku上,它具有的启用了证书检查STDLIB HTTP客户。

The code worked for you locally and didn't work on heroku, most likely, because of the different python versions used. I suspect you are using 2.7.9 runtime on heroku, which has enabled certificate checks for stdlib http clients.

阅读全文

相关推荐

最新文章