mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 01:23:32 -06:00
Return error if datasource TLS CA not parsed
This commit is contained in:
parent
e23c678df9
commit
f6aa0e41e5
@ -3,6 +3,7 @@ package models
|
|||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
@ -71,13 +72,13 @@ func (ds *DataSource) GetHttpTransport() (*http.Transport, error) {
|
|||||||
|
|
||||||
if tlsClientAuth || tlsAuthWithCACert {
|
if tlsClientAuth || tlsAuthWithCACert {
|
||||||
decrypted := ds.SecureJsonData.Decrypt()
|
decrypted := ds.SecureJsonData.Decrypt()
|
||||||
|
|
||||||
if tlsAuthWithCACert && len(decrypted["tlsCACert"]) > 0 {
|
if tlsAuthWithCACert && len(decrypted["tlsCACert"]) > 0 {
|
||||||
caPool := x509.NewCertPool()
|
caPool := x509.NewCertPool()
|
||||||
ok := caPool.AppendCertsFromPEM([]byte(decrypted["tlsCACert"]))
|
ok := caPool.AppendCertsFromPEM([]byte(decrypted["tlsCACert"]))
|
||||||
if ok {
|
if !ok {
|
||||||
transport.TLSClientConfig.RootCAs = caPool
|
return nil, errors.New("Failed to parse TLS CA PEM certificate")
|
||||||
}
|
}
|
||||||
|
transport.TLSClientConfig.RootCAs = caPool
|
||||||
}
|
}
|
||||||
|
|
||||||
if tlsClientAuth {
|
if tlsClientAuth {
|
||||||
|
Loading…
Reference in New Issue
Block a user