Add --insecure-tls flag to disable SSL cert verification

Signed-off-by: Sam Lucidi <slucidi@redhat.com>
This commit is contained in:
Sam Lucidi
2019-12-12 17:10:23 -05:00
parent 1827b16ade
commit 897d8e662c
4 changed files with 21 additions and 0 deletions

View File

@@ -22,6 +22,9 @@ type TransportOptions struct {
// contains the name of a file containing the TLS client certificate and private key in PEM format
TLSClientCertKeyFilename string
// Skip TLS certificate verification
InsecureTLS bool
}
// readPEMCertKey reads a file and returns the PEM encoded certificate and key
@@ -79,6 +82,10 @@ func Transport(opts TransportOptions) (http.RoundTripper, error) {
TLSClientConfig: &tls.Config{},
}
if opts.InsecureTLS {
tr.TLSClientConfig.InsecureSkipVerify = true
}
if opts.TLSClientCertKeyFilename != "" {
certs, key, err := readPEMCertKey(opts.TLSClientCertKeyFilename)
if err != nil {