Преглед на файлове

Merge 783362322a73b7a9eb85db2a662d3b5a2cc1a5ab into b7c059886c0898436db90b4615a27cfb4d93ce34

Luis Cavalcante преди 1 година
родител
ревизия
d30ecd082d
променени са 1 файла, в които са добавени 19 реда и са изтрити 0 реда
  1. 19 0
      client/options.go

+ 19 - 0
client/options.go

@@ -154,6 +154,25 @@ func WithTLSClientConfig(cacertPath, certPath, keyPath string) Opt {
 	}
 }
 
+func WithInsecureSkipVerifyTLSClientConfig(certPath, keyPath string) Opt {
+	return func(c *Client) error {
+		opts := tlsconfig.Options{
+			CertFile:           certPath,
+			KeyFile:            keyPath,
+			InsecureSkipVerify: true,
+		}
+		config, err := tlsconfig.Client(opts)
+		if err != nil {
+			return errors.Wrap(err, "failed to create tls config")
+		}
+		if transport, ok := c.client.Transport.(*http.Transport); ok {
+			transport.TLSClientConfig = config
+			return nil
+		}
+		return errors.Errorf("cannot apply tls config to transport: %T", c.client.Transport)
+	}
+}
+
 // WithTLSClientConfigFromEnv configures the client's TLS settings with the
 // settings in the DOCKER_CERT_PATH ([EnvOverrideCertPath]) and DOCKER_TLS_VERIFY
 // ([EnvTLSVerify]) environment variables. If DOCKER_CERT_PATH is not set or empty,