Create a NewCertPool for custom CA certificate

This commit is contained in:
Matthias Loibl 2018-12-03 19:47:37 +01:00
parent 4a16ae6d9a
commit 9fb46c3c55
No known key found for this signature in database
GPG key ID: B1C7DF661ABB2C1A

View file

@ -272,14 +272,12 @@ func makeKubeconfigHTTPClient(inClusterAuth bool, kubeConfigPath string) (*http.
}
func makePrometheusCAClient(caFilename string) (*http.Client, error) {
pool, err := x509.SystemCertPool()
if err != nil {
return nil, fmt.Errorf("failed to read system certificates: %v", err)
}
data, err := ioutil.ReadFile(caFilename)
if err != nil {
return nil, fmt.Errorf("failed to read prometheus-ca-file: %v", err)
}
pool := x509.NewCertPool()
if !pool.AppendCertsFromPEM(data) {
return nil, fmt.Errorf("no certs found in prometheus-ca-file")
}