Cant use dot for bucketname #421

Closed
openkava opened this Issue Dec 2, 2011 · 7 comments

7 participants

@openkava

code is here :
from boto.s3.connection import S3Connection
conn =S3Connection('XXXXX','XXXXX')
rs=conn.get_all_buckets()
for b in rs:
print b.name
b=conn.get_bucket('AAAAA')

for key in b.list():

    print key.name 

1 I create two bucket ( photo_bucket ,photo.mydomain.com ) when I get the bucket name (photo_bucket) have no char '.' in it .it works . but when I use "photo.mydomain.com" ,it has error .

InvalidCertificateException: Host photo.mydomain.com.s3.amazonaws.com returned an invalid certificate (hostname mismatch): {'notAfter': 'Dec 18 23:59:59 2013 GMT', 'subjectAltName': (('DNS', '.s3.amazonaws.com'), ('DNS', 's3.amazonaws.com')), 'subject': ((('countryName', u'US'),), (('stateOrProvinceName', u'Washington'),), (('localityName', u'Seattle'),), (('organizationName', u'Amazon.com Inc.'),), (('commonName', u'.s3.amazonaws.com'),))}

can anyone fix it ?

@garnaat
the boto project member

I don't understand the error you are receiving. I am unable to reproduce this:

In [1]: import boto

In [2]: c = boto.connect_s3()

In [3]: c.get_all_buckets()
Out[3]: 
[...,
 <Bucket: test-1256501564>,
 <Bucket: version-1297645329>,
 <Bucket: version-1317820845>,
 <Bucket: www.cloudright.com>]

In [4]: b = c.lookup('www.cloudright.com')

In [5]: for k in b:
   ...:     print k.name
   ...: 
.htaccess
CloudRightWebSite
about.html
consulting.html
contact.html
foss.html
index.html
index.php
new/aboutus.html
new/favicon.ico
new/foss.html
new/index.html
new/media/CCDoneRight.png
new/media/CloudRight.css
new/media/CloudRightLogo.png
new/media/CloudRightLogoNew.png
new/media/YouWe.gif
new/media/a
new/media/a_002
new/media/ga.js
new/media/index.php
new/media/jquery-ui-personalized-1.js
new/media/jquery.js
new/media/page.js
new/media/quoteNow.png
new/media/tabTopHome.gif
new/media/transparent.gif
static/css/base.css
static/img/logo.png
static/img/logo1.png
static/img/twitter.gif
static/img/twitter.png
training.html
@openkava

thanks for you reply .
I download the newest boto .and test it . My system is windows 7.
I have set cnames :sg.openkava.com as s3.openkava.com.s3.amazonaws.com

here is my code:
########

import sys
import glob
import os
from boto.s3.connection import S3Connection
from boto.s3.connection import Location
from boto.s3.key import Key

conn =S3Connection('xxxxxx','xxxxxx') # xxxx is my private amazon aceess code .
b = conn.lookup('sg.openkava.com ') # here is my bucket name
for k in b :
print k.name

##########
idle generate it:
Traceback (most recent call last):
File "D:/amazon/python/amazontest.py", line 38, in
for k in b :
TypeError: 'NoneType' object is not iterable

also I use :b=conn.get_bucket('s3.openkava.com')

it give:
boto.https_connection.InvalidCertificateException: Host s3.openkava.com.s3.amazo
naws.com returned an invalid certificate (remote hostname "s3.openkava.com.s3.am
azonaws.com" does not match certificate): {'notAfter': 'Dec 18 23:59:59 2013 GMT
', 'subjectAltName': (('DNS', '.s3.amazonaws.com'), ('DNS', 's3.amazonaws.com')
), 'subject': ((('countryName', u'US'),), (('stateOrProvinceName', u'Washington'
),), (('localityName', u'Seattle'),), (('organizationName', u'Amazon.com Inc.'),
), (('commonName', u'
.s3.amazonaws.com'),))}

also I create new bucket name :test.openkava.com
it give the same error :
boto.https_connection.InvalidCertificateException: Host test.openkava.com.s3.ama
zonaws.com returned an invalid certificate (remote hostname "test.openkava.com.s
3.amazonaws.com" does not match certificate): {'notAfter': 'Dec 18 23:59:59 2013
GMT', 'subjectAltName': (('DNS', '.s3.amazonaws.com'), ('DNS', 's3.amazonaws.c
om')), 'subject': ((('countryName', u'US'),), (('stateOrProvinceName', u'Washing
ton'),), (('localityName', u'Seattle'),), (('organizationName', u'Amazon.com Inc
.'),), (('commonName', u'
.s3.amazonaws.com'),))}
Does it need to config in amazon s3 ? or where do to it?

@thinkjson

I can confirm this behavior. b is None and get_bucket returns boto.https_connection.InvalidCertificateException. Is there a way to disable certificate checking? Because with a dot in the name, the url pattern on the SSL certificate won't match.

@borismus

Seeing this as well. Perhaps there's a way to force boto to use HTTP?

@borismus

Found it. My ~/.boto configuration file had the line:

https_validate_certificates = True

By changing the value to False, I resolved my issue. Hope this helps!

@toastdriven toastdriven reopened this Jul 11, 2013
@jamesls
the boto project member

You can also change the calling format via the calling_format arg to not use the SubdomainCallingFormat instead of disabling SSL.

@jamesls jamesls closed this Jul 11, 2013
@ricardocabral

This worked for me:

from boto.s3.connection import ProtocolIndependentOrdinaryCallingFormat
conn = S3Connection(access_key, secret_key,calling_format=ProtocolIndependentOrdinaryCallingFormat())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment