mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-06 01:38:10 +00:00
Create a NewCertPool for custom CA certificate
This commit is contained in:
parent
4a16ae6d9a
commit
9fb46c3c55
1 changed files with 2 additions and 4 deletions
|
|
@ -272,14 +272,12 @@ func makeKubeconfigHTTPClient(inClusterAuth bool, kubeConfigPath string) (*http.
|
||||||
}
|
}
|
||||||
|
|
||||||
func makePrometheusCAClient(caFilename string) (*http.Client, error) {
|
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)
|
data, err := ioutil.ReadFile(caFilename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read prometheus-ca-file: %v", err)
|
return nil, fmt.Errorf("failed to read prometheus-ca-file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pool := x509.NewCertPool()
|
||||||
if !pool.AppendCertsFromPEM(data) {
|
if !pool.AppendCertsFromPEM(data) {
|
||||||
return nil, fmt.Errorf("no certs found in prometheus-ca-file")
|
return nil, fmt.Errorf("no certs found in prometheus-ca-file")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue