Skip to content

Commit

Permalink
fix(cli): clone the transport with tls-skip-verify (#2369)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Dec 1, 2024
1 parent c2f179f commit 19a0202
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmd/setup.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cmd

import (
"crypto/tls"
"crypto/x509"
"encoding/pem"
"fmt"
Expand Down Expand Up @@ -51,8 +50,11 @@ func newClient(ctx *cli.Context, acc registration.User, keyType certcrypto.KeyTy
}

if ctx.Bool(flgTLSSkipVerify) {
config.HTTPClient.Transport = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
defaultTransport, ok := config.HTTPClient.Transport.(*http.Transport)
if ok { // This is always true because the default client used by the CLI defined the transport.
tr := defaultTransport.Clone()
tr.TLSClientConfig.InsecureSkipVerify = true
config.HTTPClient.Transport = tr
}
}

Expand Down

0 comments on commit 19a0202

Please sign in to comment.