Skip to content

Commit 02dde93

Browse files
committed
Verify success of parsing OpenStack cloud cacert
If no certificate is set to `OPENSTACK_CLOUD_CACERT_B64` env varaible, it defaults to an empty string encoded. This can cause failure to connect to OpenStack API when it uses a certificate bundle that is supplied by the OS, instead of a private certificate. This commit fixes the issue by checking if the certificate was parsed successfully and if not attempts to use the host's root CA.
1 parent 3652e4b commit 02dde93

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/scope/provider.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,11 @@ func NewProviderClient(cloud clientconfig.Cloud, caCert []byte, logger logr.Logg
165165
}
166166
if caCert != nil {
167167
config.RootCAs = x509.NewCertPool()
168-
config.RootCAs.AppendCertsFromPEM(caCert)
168+
ok := config.RootCAs.AppendCertsFromPEM(caCert)
169+
if !ok {
170+
// If no certificates were successfully parsed, set RootCAs to nil to use the host's root CA
171+
config.RootCAs = nil
172+
}
169173
}
170174

171175
provider.HTTPClient.Transport = &http.Transport{Proxy: http.ProxyFromEnvironment, TLSClientConfig: config}

0 commit comments

Comments
 (0)