mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05: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:
parent
dcffd87e08
commit
7cea3f7da4
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user