@@ -19,13 +19,10 @@ package util
1919import (
2020 "crypto/tls"
2121 "crypto/x509"
22+ . "github.com/google/go-containerregistry/pkg/name"
2223 "github.com/sirupsen/logrus"
2324 "io/ioutil"
24- "net"
2525 "net/http"
26- "time"
27-
28- . "github.com/google/go-containerregistry/pkg/name"
2926)
3027
3128var tlsConfiguration = struct {
@@ -48,7 +45,8 @@ func ConfigureTLS(skipTsVerifyRegistries []string, registriesToCertificates map[
4845}
4946
5047func BuildTransport (registry Registry ) http.RoundTripper {
51- var tr http.RoundTripper = newTransport ()
48+ var tr http.RoundTripper = http .DefaultTransport .(* http.Transport ).Clone ()
49+
5250 if _ , present := tlsConfiguration .skipTLSVerifyRegistries [registry .RegistryStr ()]; present {
5351 tr .(* http.Transport ).TLSClientConfig = & tls.Config {
5452 InsecureSkipVerify : true ,
@@ -66,22 +64,6 @@ func BuildTransport(registry Registry) http.RoundTripper {
6664 return tr
6765}
6866
69- // TODO replace it with "http.DefaultTransport.(*http.Transport).Clone()" once in golang 1.12
70- func newTransport () http.RoundTripper {
71- return & http.Transport {
72- Proxy : http .ProxyFromEnvironment ,
73- DialContext : (& net.Dialer {
74- Timeout : 30 * time .Second ,
75- KeepAlive : 30 * time .Second ,
76- DualStack : true ,
77- }).DialContext ,
78- MaxIdleConns : 100 ,
79- IdleConnTimeout : 90 * time .Second ,
80- TLSHandshakeTimeout : 10 * time .Second ,
81- ExpectContinueTimeout : 1 * time .Second ,
82- }
83- }
84-
8567func appendCertificate (pool * x509.CertPool , path string ) error {
8668 pem , err := ioutil .ReadFile (path )
8769 if err != nil {
0 commit comments