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: hostname 'ourcompany.images.s3.amazonaws.com' doesn't match either of '*.s3.amazonaws.com', 's3.amazonaws.com'
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'
According to the relevant github issue, add this to the configuration:
[s3]
calling_format = boto.s3.connection.OrdinaryCallingFormat
Or, specify the calling_format
while instantiating an S3Connection
:
from boto.s3.connection import OrdinaryCallingFormat
conn = S3Connection(access_key, secret_key, calling_format=OrdinaryCallingFormat())
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With