diff --git a/client-s3.go b/client-s3.go index 10605983..bc0c67ac 100644 --- a/client-s3.go +++ b/client-s3.go @@ -92,7 +92,7 @@ func newFactory() func(config *Config) (Client, *probe.Error) { if api, found = clientCache[confSum]; !found { // Not found. Instantiate a new minio var e error - if config.Signature == "S3v2" { + if strings.ToUpper(config.Signature) == "S3V2" { // if Signature version '2' use NewV2 directly. api, e = minio.NewV2(hostName, config.AccessKey, config.SecretKey, inSecure) } else { diff --git a/config-host-main.go b/config-host-main.go index f1860aac..e92e4410 100644 --- a/config-host-main.go +++ b/config-host-main.go @@ -165,11 +165,9 @@ func checkConfigHostAddSyntax(ctx *cli.Context) { "Invalid secret key ‘"+secretKey+"’.") } - switch api { - case "S3v2", "S3v4", "": - default: + if api != "" && !isValidAPI(api) { // Empty value set to default "S3v4". fatalIf(errInvalidArgument().Trace(api), - "Unrecognized API signature. Valid options are ‘[ S3v4, S3v2 ]’.") + "Unrecognized API signature. Valid options are ‘[S3v4, S3v2]’.") } } @@ -214,7 +212,7 @@ func mainConfigHost(ctx *cli.Context) { accessKey := args.Get(2) secretKey := args.Get(3) api := args.Get(4) - if strings.TrimSpace(api) == "" { + if api == "" { api = "S3v4" } hostCfg := hostConfigV8{ diff --git a/config-utils.go b/config-utils.go index 56704a02..c7b243ff 100644 --- a/config-utils.go +++ b/config-utils.go @@ -53,3 +53,13 @@ func isValidHostURL(hostURL string) bool { } return true } + +// isValidAPI - Validates if API signature string of supported type. +func isValidAPI(api string) bool { + switch strings.ToLower(api) { + case "s3v2", "s3v4": + return true + default: + return false + } +}