Skip to content

Commit

Permalink
workaround for strict hostname verification and periods in S3 buckets
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Oberstein committed Jan 5, 2015
1 parent 45d39c8 commit 195ba64
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

setup (
name = 'taschenmesser',
version = '0.1.5',
version = '0.1.6',
description = 'Taschenmesser, a toolbelt with plugins for SCons',
long_description = LONGSDESC,
license = 'Apache License 2.0',
Expand Down
21 changes: 21 additions & 0 deletions taschenmesser/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,27 @@

__all__ = ['exists', 'generate']

# The following monkey patch is for buckets containing periods
# and due to the following
# https://github.com/boto/boto/issues/2836

# disable hostname verification altogether
# import ssl
# if hasattr(ssl, '_create_unverified_context'):
# ssl._create_default_https_context = ssl._create_unverified_context

# more specific monkey patch:
import ssl
_old_match_hostname = ssl.match_hostname

def _new_match_hostname(cert, hostname):
if hostname.endswith('.s3.amazonaws.com'):
pos = hostname.find('.s3.amazonaws.com')
hostname = hostname[:pos].replace('.', '') + hostname[pos:]
return _old_match_hostname(cert, hostname)

ssl.match_hostname = _new_match_hostname


import hashlib

Expand Down

0 comments on commit 195ba64

Please sign in to comment.