Skip to content

Commit d63576b

Browse files
jmdelafemjuraga
authored andcommitted
BUG/MINOR: cert-info: enhance leaf certificate selection to include DNS names
Extending the logic to check if both CommonName or SubjectAlternativeNames are not empty. This fixes the cases where names are too long and have no CN but only SAN.
1 parent 3b9a18e commit d63576b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

storage/cert-info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func findLeafCertificate(certs []*x509.Certificate) (*x509.Certificate, error) {
160160

161161
// Find the starting certificate (a certificate whose issuer is not in the list)
162162
for _, cert := range certs {
163-
if !cert.IsCA && cert.Subject.CommonName != "" && !isIssuer[cert.Subject.String()] {
163+
if !cert.IsCA && (cert.Subject.CommonName != "" || len(cert.DNSNames) != 0) && !isIssuer[cert.Subject.String()] {
164164
return cert, nil
165165
}
166166
}

0 commit comments

Comments
 (0)