Skip to content

Commit 04467c6

Browse files
Merge pull request #1822 from vrutkovs/cert-inspection-configmap-keys
certgraphanalysis: add more locations for CA locations
2 parents e158d5a + 4d256a9 commit 04467c6

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

pkg/certs/cert-inspection/certgraphanalysis/analyzer.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package certgraphanalysis
22

33
import (
44
"fmt"
5+
"slices"
56

67
"github.com/openshift/library-go/pkg/certs/cert-inspection/certgraphapi"
78
certificatesv1 "k8s.io/api/certificates/v1"
@@ -13,6 +14,16 @@ import (
1314
"k8s.io/client-go/util/cert"
1415
)
1516

17+
var caBundleKeys = []string{
18+
"ca-bundle.crt",
19+
"client-ca-file",
20+
"client-ca.crt",
21+
"metrics-ca-bundle.crt",
22+
"requestheader-client-ca-file",
23+
"image-registry.openshift-image-registry.svc..5000",
24+
"image-registry.openshift-image-registry.svc.cluster.local..5000",
25+
}
26+
1627
func InspectSecret(obj *corev1.Secret) ([]*certgraphapi.CertKeyPair, error) {
1728
tlsCrt, isTLS := obj.Data["tls.crt"]
1829
if !isTLS || len(tlsCrt) == 0 {
@@ -60,8 +71,18 @@ func InspectConfigMap(obj *corev1.ConfigMap) (*certgraphapi.CertificateAuthority
6071
return details, nil
6172
}
6273

63-
caBundle, ok := obj.Data["ca-bundle.crt"]
64-
if !ok || len(caBundle) == 0 {
74+
var caBundle string
75+
for key := range obj.Data {
76+
if !slices.Contains(caBundleKeys, key) {
77+
continue
78+
}
79+
if value := obj.Data[key]; len(value) > 0 {
80+
caBundle = value
81+
break
82+
}
83+
}
84+
85+
if len(caBundle) == 0 {
6586
return nil, nil
6687
}
6788

0 commit comments

Comments
 (0)