在Heroku上使用时,宝途无法连接到S3水桶时期在他们的名字, [英] Can't connect to S3 buckets with periods in their name, when using Boto on Heroku

查看:235
本文介绍了在Heroku上使用时,宝途无法连接到S3水桶时期在他们的名字,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们得到一个证书错误试图连接到我们使用的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 在实例的<一个href="http://boto.readthedocs.org/en/latest/ref/s3.html#boto.s3.connection.S3Connection"><$c$c>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.

这篇关于在Heroku上使用时,宝途无法连接到S3水桶时期在他们的名字,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆