make s3Config Transport a roundTripper (#4914)

This commit is contained in:
Harshavardhana
2024-04-30 10:44:48 -07:00
committed by GitHub
parent 9fad66d824
commit dcb911bed9
3 changed files with 28 additions and 7 deletions
+10 -5
View File
@@ -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
}
+1 -1
View File
@@ -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
+17 -1
View File
@@ -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 <http://www.gnu.org/licenses/>.
package cmd
/**/
import (
"bytes"
"crypto/md5"