Merge pull request #19 from StrongMonkey/cert

Don't append CA if url is behind public CA
This commit is contained in:
Darren Shepherd 2021-05-03 18:38:07 -07:00 committed by GitHub
commit 97ff535abc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,10 +26,12 @@ func ListenAndServe(ctx context.Context, url string, caCert []byte, token string
InsecureSkipVerify: true, InsecureSkipVerify: true,
} }
} else if len(caCert) > 0 { } else if len(caCert) > 0 {
pool := x509.NewCertPool() if _, err := http.Get(url); err != nil {
pool.AppendCertsFromPEM(caCert) pool := x509.NewCertPool()
dialer.TLSClientConfig = &tls.Config{ pool.AppendCertsFromPEM(caCert)
RootCAs: pool, dialer.TLSClientConfig = &tls.Config{
RootCAs: pool,
}
} }
} }