crypto: Treat CommonName as optional (#1064)
This commit is contained in:
parent
2e30fd0ba8
commit
5cdc0002e9
1 changed files with 8 additions and 2 deletions
|
@ -199,7 +199,10 @@ func ParsePEMCertificate(cert []byte) (*x509.Certificate, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExtractDomains(cert *x509.Certificate) []string {
|
func ExtractDomains(cert *x509.Certificate) []string {
|
||||||
domains := []string{cert.Subject.CommonName}
|
var domains []string
|
||||||
|
if cert.Subject.CommonName != "" {
|
||||||
|
domains = append(domains, cert.Subject.CommonName)
|
||||||
|
}
|
||||||
|
|
||||||
// Check for SAN certificate
|
// Check for SAN certificate
|
||||||
for _, sanDomain := range cert.DNSNames {
|
for _, sanDomain := range cert.DNSNames {
|
||||||
|
@ -213,7 +216,10 @@ func ExtractDomains(cert *x509.Certificate) []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExtractDomainsCSR(csr *x509.CertificateRequest) []string {
|
func ExtractDomainsCSR(csr *x509.CertificateRequest) []string {
|
||||||
domains := []string{csr.Subject.CommonName}
|
var domains []string
|
||||||
|
if csr.Subject.CommonName != "" {
|
||||||
|
domains = append(domains, csr.Subject.CommonName)
|
||||||
|
}
|
||||||
|
|
||||||
// loop over the SubjectAltName DNS names
|
// loop over the SubjectAltName DNS names
|
||||||
for _, sanName := range csr.DNSNames {
|
for _, sanName := range csr.DNSNames {
|
||||||
|
|
Loading…
Reference in a new issue