Skip to content

Commit

Permalink
Fixes s3tools#1059 - Hack for SignatureDoesNotMatch error when host p…
Browse files Browse the repository at this point in the history
…ort 80 or 443 is specified, due to stupid servers

This 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 but looks like that it is common ...
More details here: minio/minio#9169
  • Loading branch information
fviard committed Mar 20, 2020
1 parent e4b18b1 commit 59c30c5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions S3/S3.py
Expand Up @@ -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

Expand Down

0 comments on commit 59c30c5

Please sign in to comment.