Skip to content

Commit fcf44e2

Browse files
committed
BUG/MINOR: be less restrictive when looking for a leaf certificate
Certificates generated by ACME may not have a CommonName, so we should not require it. Also accept IP address certificates.
1 parent 2ee4014 commit fcf44e2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

storage/cert-info.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ func (ci *certsInfo) parseCertificate(der []byte) error {
120120
ci.Issuers[crt.Issuer.CommonName] = struct{}{}
121121

122122
if !crt.IsCA {
123-
ci.DNS[crt.Subject.CommonName] = struct{}{}
123+
if crt.Subject.CommonName != "" {
124+
ci.DNS[crt.Subject.CommonName] = struct{}{}
125+
}
124126
// Alternate Subject Names
125127
for _, name := range crt.DNSNames {
126128
ci.DNS[name] = struct{}{}
@@ -160,7 +162,7 @@ func findLeafCertificate(certs []*x509.Certificate) (*x509.Certificate, error) {
160162

161163
// Find the starting certificate (a certificate whose issuer is not in the list)
162164
for _, cert := range certs {
163-
if !cert.IsCA && cert.Subject.CommonName != "" && !isIssuer[cert.Subject.String()] {
165+
if !cert.IsCA && (cert.Subject.CommonName != "" || len(cert.DNSNames) != 0 || len(cert.IPAddresses) != 0) && !isIssuer[cert.Subject.String()] {
164166
return cert, nil
165167
}
166168
}

0 commit comments

Comments
 (0)