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: https://github.com/minio/minio/issues/9169
... | ... |
@@ -272,6 +272,17 @@ class S3(object): |
272 | 272 |
host = getHostnameFromBucket(bucket) |
273 | 273 |
else: |
274 | 274 |
host = self.config.host_base.lower() |
275 |
+ # The following hack is needed because it looks like that some servers |
|
276 |
+ # are not respecting the HTTP spec and so will fail the signature check |
|
277 |
+ # if the port is specified in the "Host" header for default ports. |
|
278 |
+ # STUPIDIEST THING EVER FOR A SERVER... |
|
279 |
+ # See: https://github.com/minio/minio/issues/9169 |
|
280 |
+ if self.config.use_https: |
|
281 |
+ if host.endswith(':443'): |
|
282 |
+ host = host[:-4] |
|
283 |
+ elif host.endswith(':80'): |
|
284 |
+ host = host[:-3] |
|
285 |
+ |
|
275 | 286 |
debug('get_hostname(%s): %s' % (bucket, host)) |
276 | 287 |
return host |
277 | 288 |
|