| 1 | //go:build go1.7 || go1.8 |
| 2 | |
| 3 | /* |
| 4 | * MinIO Go Library for Amazon S3 Compatible Cloud Storage |
| 5 | * Copyright 2017-2018 MinIO, Inc. |
| 6 | * |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | */ |
| 19 | |
| 20 | package minioscip-go gomod github.com/minio/minio-go/v7 . `github.com/minio/minio-go/v7`/ |
| 21 | |
| 22 | import ( |
| 23 | "crypto/tlsscip-go gomod github.com/golang/go/src go1.25 `crypto/tls`/" |
| 24 | "crypto/x509scip-go gomod github.com/golang/go/src go1.25 `crypto/x509`/" |
| 25 | "netscip-go gomod github.com/golang/go/src go1.25 net/" |
| 26 | "net/httpscip-go gomod github.com/golang/go/src go1.25 `net/http`/" |
| 27 | "osscip-go gomod github.com/golang/go/src go1.25 os/" |
| 28 | "timescip-go gomod github.com/golang/go/src go1.25 time/" |
| 29 | ) |
| 30 | |
| 31 | // mustGetSystemCertPool - return system CAs or empty pool in case of error (or windows) |
| 32 | func mustGetSystemCertPoolscip-go gomod github.com/minio/minio-go/v7 . `github.com/minio/minio-go/v7`/mustGetSystemCertPool().() *x509scip-go gomod github.com/golang/go/src go1.25 `crypto/x509`/.CertPoolscip-go gomod github.com/golang/go/src go1.25 `crypto/x509`/CertPool# { |
| 33 | pool, err := x509scip-go gomod github.com/golang/go/src go1.25 `crypto/x509`/.SystemCertPoolscip-go gomod github.com/golang/go/src go1.25 `crypto/x509`/SystemCertPool().() |
| 34 | if err != nil { |
| 35 | return x509scip-go gomod github.com/golang/go/src go1.25 `crypto/x509`/.NewCertPoolscip-go gomod github.com/golang/go/src go1.25 `crypto/x509`/NewCertPool().() |
| 36 | } |
| 37 | return pool |
| 38 | } |
| 39 | |
| 40 | // DefaultTransport - this default transport is similar to |
| 41 | // http.DefaultTransport but with additional param DisableCompression |
| 42 | // is set to true to avoid decompressing content with 'gzip' encoding. |
| 43 | var DefaultTransportscip-go gomod github.com/minio/minio-go/v7 . `github.com/minio/minio-go/v7`/DefaultTransport. = func(securescip-go gomod github.com/minio/minio-go/v7 . `github.com/minio/minio-go/v7`/DefaultTransport:secure. bool) (*httpscip-go gomod github.com/golang/go/src go1.25 `net/http`/.Transportscip-go gomod github.com/golang/go/src go1.25 `net/http`/Transport#, error) { |
| 44 | tr := &httpscip-go gomod github.com/golang/go/src go1.25 `net/http`/.Transportscip-go gomod github.com/golang/go/src go1.25 `net/http`/Transport#{ |
| 45 | Proxyscip-go gomod github.com/golang/go/src go1.25 `net/http`/Transport#Proxy.: httpscip-go gomod github.com/golang/go/src go1.25 `net/http`/.ProxyFromEnvironmentscip-go gomod github.com/golang/go/src go1.25 `net/http`/ProxyFromEnvironment()., |
| 46 | DialContextscip-go gomod github.com/golang/go/src go1.25 `net/http`/Transport#DialContext.: (&netscip-go gomod github.com/golang/go/src go1.25 net/.Dialerscip-go gomod github.com/golang/go/src go1.25 net/Dialer#{ |
| 47 | Timeoutscip-go gomod github.com/golang/go/src go1.25 net/Dialer#Timeout.: 30 * timescip-go gomod github.com/golang/go/src go1.25 time/.Secondscip-go gomod github.com/golang/go/src go1.25 time/Second., |
| 48 | KeepAlivescip-go gomod github.com/golang/go/src go1.25 net/Dialer#KeepAlive.: 30 * timescip-go gomod github.com/golang/go/src go1.25 time/.Secondscip-go gomod github.com/golang/go/src go1.25 time/Second., |
| 49 | }).DialContextscip-go gomod github.com/golang/go/src go1.25 net/Dialer#DialContext()., |
| 50 | MaxIdleConnsscip-go gomod github.com/golang/go/src go1.25 `net/http`/Transport#MaxIdleConns.: 256, |
| 51 | MaxIdleConnsPerHostscip-go gomod github.com/golang/go/src go1.25 `net/http`/Transport#MaxIdleConnsPerHost.: 16, |
| 52 | ResponseHeaderTimeoutscip-go gomod github.com/golang/go/src go1.25 `net/http`/Transport#ResponseHeaderTimeout.: timescip-go gomod github.com/golang/go/src go1.25 time/.Minutescip-go gomod github.com/golang/go/src go1.25 time/Minute., |
| 53 | IdleConnTimeoutscip-go gomod github.com/golang/go/src go1.25 `net/http`/Transport#IdleConnTimeout.: timescip-go gomod github.com/golang/go/src go1.25 time/.Minutescip-go gomod github.com/golang/go/src go1.25 time/Minute., |
| 54 | TLSHandshakeTimeoutscip-go gomod github.com/golang/go/src go1.25 `net/http`/Transport#TLSHandshakeTimeout.: 10 * timescip-go gomod github.com/golang/go/src go1.25 time/.Secondscip-go gomod github.com/golang/go/src go1.25 time/Second., |
| 55 | ExpectContinueTimeoutscip-go gomod github.com/golang/go/src go1.25 `net/http`/Transport#ExpectContinueTimeout.: 10 * timescip-go gomod github.com/golang/go/src go1.25 time/.Secondscip-go gomod github.com/golang/go/src go1.25 time/Second., |
| 56 | // Set this value so that the underlying transport round-tripper |
| 57 | // doesn't try to auto decode the body of objects with |
| 58 | // content-encoding set to `gzip`. |
| 59 | // |
| 60 | // Refer: |
| 61 | // https://golang.org/src/net/http/transport.go?h=roundTrip#L1843 |
| 62 | DisableCompressionscip-go gomod github.com/golang/go/src go1.25 `net/http`/Transport#DisableCompression.: true, |
| 63 | } |
| 64 | |
| 65 | if securescip-go gomod github.com/minio/minio-go/v7 . `github.com/minio/minio-go/v7`/DefaultTransport:secure. { |
| 66 | tr.TLSClientConfigscip-go gomod github.com/golang/go/src go1.25 `net/http`/Transport#TLSClientConfig. = &tlsscip-go gomod github.com/golang/go/src go1.25 `crypto/tls`/.Configscip-go gomod github.com/golang/go/src go1.25 `crypto/tls`/Config#{ |
| 67 | // Can't use SSLv3 because of POODLE and BEAST |
| 68 | // Can't use TLSv1.0 because of POODLE and BEAST using CBC cipher |
| 69 | // Can't use TLSv1.1 because of RC4 cipher usage |
| 70 | MinVersionscip-go gomod github.com/golang/go/src go1.25 `crypto/tls`/Config#MinVersion.: tlsscip-go gomod github.com/golang/go/src go1.25 `crypto/tls`/.VersionTLS12scip-go gomod github.com/golang/go/src go1.25 `crypto/tls`/VersionTLS12., |
| 71 | } |
| 72 | if f := osscip-go gomod github.com/golang/go/src go1.25 os/.Getenvscip-go gomod github.com/golang/go/src go1.25 os/Getenv().("SSL_CERT_FILE"); f != "" { |
| 73 | rootCAs := mustGetSystemCertPoolscip-go gomod github.com/minio/minio-go/v7 . `github.com/minio/minio-go/v7`/mustGetSystemCertPool().() |
| 74 | data, err := osscip-go gomod github.com/golang/go/src go1.25 os/.ReadFilescip-go gomod github.com/golang/go/src go1.25 os/ReadFile().(f) |
| 75 | if err == nil { |
| 76 | rootCAs.AppendCertsFromPEMscip-go gomod github.com/golang/go/src go1.25 `crypto/x509`/CertPool#AppendCertsFromPEM().(data) |
| 77 | } |
| 78 | tr.TLSClientConfigscip-go gomod github.com/golang/go/src go1.25 `net/http`/Transport#TLSClientConfig..RootCAsscip-go gomod github.com/golang/go/src go1.25 `crypto/tls`/Config#RootCAs. = rootCAs |
| 79 | } |
| 80 | } |
| 81 | return tr, nil |
| 82 | } |