Skip to content

Commit

Permalink
Merge pull request #329 from jordanjean/proxy-support
Browse files Browse the repository at this point in the history
Proxy Support
  • Loading branch information
ibuildthecloud authored Feb 6, 2020
2 parents 6a8b7a4 + 39e5473 commit ef3920a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions clientbase/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ func NewAPIClient(opts *ClientOpts) (APIBaseClient, error) {
client.Timeout = opts.Timeout

if opts.CACerts != "" {
if Debug {
fmt.Println("Some CAcerts are provided.")
}
roots := x509.NewCertPool()
ok := roots.AppendCertsFromPEM([]byte(opts.CACerts))
if !ok {
Expand All @@ -194,15 +197,30 @@ func NewAPIClient(opts *ClientOpts) (APIBaseClient, error) {
TLSClientConfig: &tls.Config{
RootCAs: roots,
},
Proxy: http.ProxyFromEnvironment,
}
client.Transport = tr
}

if opts.Insecure {
if Debug {
fmt.Println("Insecure TLS set.")
}
tr := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: opts.Insecure,
},
Proxy: http.ProxyFromEnvironment,
}
client.Transport = tr
}

if !(opts.Insecure) && (opts.CACerts == "") {
if Debug {
fmt.Println("Insecure TLS not set and no CAcerts is provided.")
}
tr := &http.Transport{
Proxy: http.ProxyFromEnvironment,
}
client.Transport = tr
}
Expand Down

0 comments on commit ef3920a

Please sign in to comment.