Skip to content

Commit

Permalink
CB-28539: Clone the default http transport the https transport
Browse files Browse the repository at this point in the history
We need to copy the Transport struct used in the default HTTP client, as the default Transport has several timeout values set, which we need to copy if we want to have the same behaviour as with HTTP disabled.
  • Loading branch information
szabolcs-horvath committed Feb 11, 2025
1 parent ebb617c commit 8eb4219
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions saltboot/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ func determineProtocol(httpsEnabled bool) string {

func getHttpClient(httpsEnabled bool) *http.Client {
if httpsEnabled {
transport := http.DefaultTransport.(*http.Transport).Clone()
if transport.TLSClientConfig == nil {
transport.TLSClientConfig = &tls.Config{}
}
transport.TLSClientConfig.InsecureSkipVerify = true

return &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
Transport: transport,
}
} else {
return &http.Client{}
Expand Down

0 comments on commit 8eb4219

Please sign in to comment.