Skip to content

Commit 85ac017

Browse files
Merge pull request #1190 from shiftstack/cco-managed-cacert
OSASINFRA-3747: Prefer CA cert from credentials secret
2 parents ade277a + 32c6df7 commit 85ac017

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

pkg/storage/swift/swift.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,24 @@ func GetConfig(listers *regopclient.StorageListers) (*Swift, error) {
174174
// CABundle returns either the configured CA bundle or indicates that the
175175
// system trust bundle should be used instead.
176176
func (d *driver) CABundle() (string, bool, error) {
177+
sec, err := d.Listers.Secrets.Get(defaults.CloudCredentialsName)
178+
if err != nil {
179+
if !apimachineryerrors.IsNotFound(err) {
180+
return "", false, err
181+
}
182+
} else {
183+
caBundle := string(sec.Data["cacert"])
184+
if caBundle != "" {
185+
return caBundle, false, nil
186+
}
187+
}
188+
189+
// Fallback for retrieving CA cert from the CCM config. Starting in
190+
// OCP 4.19, cloud-credential-operator provides this in the credential
191+
// secret, as seen above, so this is no longer necessary outside of
192+
// upgrade scenarios.
193+
// TODO(stephenfin): Remove in 4.20
194+
177195
cm, err := d.Listers.OpenShiftConfig.Get("cloud-provider-config")
178196
if apimachineryerrors.IsNotFound(err) {
179197
return "", true, nil
@@ -182,10 +200,10 @@ func (d *driver) CABundle() (string, bool, error) {
182200
return "", false, err
183201
}
184202
caBundle := string(cm.Data["ca-bundle.pem"])
185-
if caBundle == "" {
186-
return "", true, nil
203+
if caBundle != "" {
204+
return caBundle, false, nil
187205
}
188-
return caBundle, false, nil
206+
return "", true, nil
189207
}
190208

191209
type ErrContainerEndpointNotFound struct {

0 commit comments

Comments
 (0)