Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
Add options for custom TLS config
Browse files Browse the repository at this point in the history
Signed-off-by: Beorn Facchini <[email protected]>
  • Loading branch information
beornf committed Sep 12, 2019
1 parent 213509a commit ebd86c7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions docker/client/client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package client

import (
"crypto/tls"
"fmt"
"net/http"
"os"
Expand Down Expand Up @@ -37,6 +38,7 @@ func init() {
type Options struct {
TLS bool
TLSVerify bool
TLSConfig *tls.Config
TLSOptions tlsconfig.Options
TrustKey string
Host string
Expand Down Expand Up @@ -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,
},
}
}
Expand Down

0 comments on commit ebd86c7

Please sign in to comment.