Don't overwrite Transport's TLS config if it's been set
This commit is contained in:
parent
32068f7025
commit
6092d2c2cc
17
api/api.go
17
api/api.go
|
@ -430,17 +430,20 @@ func NewClient(config *Config) (*Client, error) {
|
||||||
// NewHttpClient returns an http client configured with the given Transport and TLS
|
// NewHttpClient returns an http client configured with the given Transport and TLS
|
||||||
// config.
|
// config.
|
||||||
func NewHttpClient(transport *http.Transport, tlsConf TLSConfig) (*http.Client, error) {
|
func NewHttpClient(transport *http.Transport, tlsConf TLSConfig) (*http.Client, error) {
|
||||||
tlsClientConfig, err := SetupTLSConfig(&tlsConf)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
transport.TLSClientConfig = tlsClientConfig
|
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Transport: transport,
|
Transport: transport,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if transport.TLSClientConfig == nil {
|
||||||
|
tlsClientConfig, err := SetupTLSConfig(&tlsConf)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
transport.TLSClientConfig = tlsClientConfig
|
||||||
|
}
|
||||||
|
|
||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue