1
0
mirror of https://github.com/minio/minio synced 2024-07-08 19:56:05 +00:00

madmin: Strip 80/443 from the endpoint when http/https (#9937)

Users having endpoints with this format http://url:80 or http://url:443
will face signature mismatch error.

The reason is that  S3 spec ignores :80 or :443 port in the endpoint
when calculating the signature, so this PR will just strip them.
This commit is contained in:
Anis Elleuch 2020-06-29 20:31:07 +01:00 committed by GitHub
parent dcffd87e08
commit 7cea3f7da4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -67,12 +67,22 @@ func getEndpointURL(endpoint string, secure bool) (*url.URL, error) {
return nil, ErrInvalidArgument(msg)
}
}
// If secure is false, use 'http' scheme.
scheme := "https"
if !secure {
scheme = "http"
}
// Strip the obvious :443 and :80 from the endpoint
// to avoid the signature mismatch error.
if secure && strings.HasSuffix(endpoint, ":443") {
endpoint = strings.TrimSuffix(endpoint, ":443")
}
if !secure && strings.HasSuffix(endpoint, ":80") {
endpoint = strings.TrimSuffix(endpoint, ":80")
}
// Construct a secured endpoint URL.
endpointURLStr := scheme + "://" + endpoint
endpointURL, err := url.Parse(endpointURLStr)