【问题标题】:Can't connect to S3 buckets with periods in their name, when using Boto on Heroku在 Heroku 上使用 Boto 时,无法连接到名称中带有句点的 S3 存储桶
【发布时间】:2015-02-23 11:33:50
【问题描述】:

我们在尝试使用 Boto 连接到 S3 存储桶时遇到证书错误。奇怪的是,只有在 Heroku 上运行时访问名称中带有句点的存储桶时才会出现这种情况。

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

引发以下错误:

证书错误:主机名“ourcompany.images.s3.amazonaws.com” 与“*.s3.amazonaws.com”、“s3.amazonaws.com”中的任何一个都不匹配

但是相同的代码在本地运行时可以正常工作,如果存储桶名称是“ourcompany-images”而不是“ourcompany.images”,也可以在 Heroku 上运行

【问题讨论】:

    标签: python heroku amazon-web-services amazon-s3 boto


    【解决方案1】:

    根据relevant github issue,将这个添加到配置中:

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

    或者,在实例化 S3Connection 时指定 calling_format

    from boto.s3.connection import OrdinaryCallingFormat
    
    conn = S3Connection(access_key, secret_key, calling_format=OrdinaryCallingFormat())
    

    代码在本地为您工作,但在 heroku 上不起作用,很可能是因为使用了不同的 python 版本。我怀疑你在 heroku 上使用 2.7.9 运行时,它有 enabled certificate checks for stdlib http clients

    【讨论】:

    猜你喜欢
    • 2014-04-22
    • 1970-01-01
    • 1970-01-01
    • 2021-09-12
    • 2012-12-23
    • 2018-04-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-23
    相关资源
    最近更新 更多