trust system pool of CAs if cacert is empty

This commit is contained in:
dovholuknf
2023-02-10 17:19:23 -05:00
parent fc73ca6c09
commit 225be8ec38
+9 -5
View File
@@ -81,12 +81,16 @@ func (self *RestClientEdgeIdentity) IsReadOnly() bool {
func (self *RestClientEdgeIdentity) NewTlsClientConfig() (*tls.Config, error) {
rootCaPool := x509.NewCertPool()
rootPemData, err := os.ReadFile(self.CaCert)
if err != nil {
return nil, errors.Errorf("could not read session certificates [%s]: %v", self.CaCert, err)
}
if self.CaCert != "" {
rootPemData, err := os.ReadFile(self.CaCert)
if err != nil {
return nil, errors.Errorf("could not read session certificates [%s]: %v", self.CaCert, err)
}
rootCaPool.AppendCertsFromPEM(rootPemData)
rootCaPool.AppendCertsFromPEM(rootPemData)
} else {
rootCaPool, _ = x509.SystemCertPool()
}
return &tls.Config{
RootCAs: rootCaPool,