diff --git a/cmd/alias-set.go b/cmd/alias-set.go index 8e5a427b..ab1af9f8 100644 --- a/cmd/alias-set.go +++ b/cmd/alias-set.go @@ -363,12 +363,16 @@ func mainAliasSet(cli *cli.Context, deprecated bool) error { // TLS root CAs of s3Config. Once configured, any client // initialized with this config trusts the given peer certificate. func configurePeerCertificate(s3Config *Config, peerCert *x509.Certificate) { + tr, ok := s3Config.Transport.(*http.Transport) + if !ok { + return + } switch { - case s3Config.Transport == nil: + case tr == nil: if globalRootCAs != nil { globalRootCAs.AddCert(peerCert) } - s3Config.Transport = &http.Transport{ + tr = &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{ Timeout: 10 * time.Second, @@ -381,12 +385,13 @@ func configurePeerCertificate(s3Config *Config, peerCert *x509.Certificate) { DisableCompression: true, TLSClientConfig: &tls.Config{RootCAs: globalRootCAs}, } - case s3Config.Transport.TLSClientConfig == nil || s3Config.Transport.TLSClientConfig.RootCAs == nil: + case tr.TLSClientConfig == nil || tr.TLSClientConfig.RootCAs == nil: if globalRootCAs != nil { globalRootCAs.AddCert(peerCert) } - s3Config.Transport.TLSClientConfig = &tls.Config{RootCAs: globalRootCAs} + tr.TLSClientConfig = &tls.Config{RootCAs: globalRootCAs} default: - s3Config.Transport.TLSClientConfig.RootCAs.AddCert(peerCert) + tr.TLSClientConfig.RootCAs.AddCert(peerCert) } + s3Config.Transport = tr } diff --git a/cmd/client.go b/cmd/client.go index 3f8cf5b8..351e7b38 100644 --- a/cmd/client.go +++ b/cmd/client.go @@ -239,7 +239,7 @@ type Config struct { ConnWriteDeadline time.Duration UploadLimit int64 DownloadLimit int64 - Transport *http.Transport + Transport http.RoundTripper } // SelectObjectOpts - opts entered for select API diff --git a/cmd/suite_test.go b/cmd/suite_test.go index c6257246..54d96e07 100644 --- a/cmd/suite_test.go +++ b/cmd/suite_test.go @@ -1,6 +1,22 @@ +// Copyright (c) 2015-2024 MinIO, Inc. +// +// This file is part of MinIO Object Storage stack +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + package cmd -/**/ import ( "bytes" "crypto/md5"