diff --git a/S3/S3.py b/S3/S3.py index f5006fef3..e6ca91b14 100644 --- a/S3/S3.py +++ b/S3/S3.py @@ -272,6 +272,17 @@ def get_hostname(self, bucket): host = getHostnameFromBucket(bucket) else: host = self.config.host_base.lower() + # The following hack is needed because it looks like that some servers + # are not respecting the HTTP spec and so will fail the signature check + # if the port is specified in the "Host" header for default ports. + # STUPIDIEST THING EVER FOR A SERVER... + # See: https://github.com/minio/minio/issues/9169 + if self.config.use_https: + if host.endswith(':443'): + host = host[:-4] + elif host.endswith(':80'): + host = host[:-3] + debug('get_hostname(%s): %s' % (bucket, host)) return host