From ebd86c75a2f8130381547fd46d2e0a5d22136ad9 Mon Sep 17 00:00:00 2001 From: Beorn Facchini Date: Fri, 17 May 2019 20:13:10 +1000 Subject: [PATCH] Add options for custom TLS config Signed-off-by: Beorn Facchini --- docker/client/client.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/docker/client/client.go b/docker/client/client.go index 70b825fe0..34e9b834f 100644 --- a/docker/client/client.go +++ b/docker/client/client.go @@ -1,6 +1,7 @@ package client import ( + "crypto/tls" "fmt" "net/http" "os" @@ -37,6 +38,7 @@ func init() { type Options struct { TLS bool TLSVerify bool + TLSConfig *tls.Config TLSOptions tlsconfig.Options TrustKey string Host string @@ -82,14 +84,17 @@ func Create(c Options) (client.APIClient, error) { var httpClient *http.Client if c.TLS { - config, err := tlsconfig.Client(c.TLSOptions) - if err != nil { - return nil, err + if c.TLSConfig == nil { + var err error + c.TLSConfig, err = tlsconfig.Client(c.TLSOptions) + if err != nil { + return nil, err + } } httpClient = &http.Client{ Transport: &http.Transport{ - TLSClientConfig: config, + TLSClientConfig: c.TLSConfig, }, } }