Fix code style issue

This commit is contained in:
Herman Slatman 2021-12-20 13:40:17 +01:00
parent bc0875bd7b
commit 80bebda69c
No known key found for this signature in database
GPG key ID: F4D8A44EA0A75A4F

View file

@ -300,19 +300,15 @@ func canonicalize(csr *x509.CertificateRequest) (canonicalized *x509.Certificate
// If these were excluded, a certificate could contain an IP as the // If these were excluded, a certificate could contain an IP as the
// common name without having been challenged. // common name without having been challenged.
if csr.Subject.CommonName != "" { if csr.Subject.CommonName != "" {
ip := net.ParseIP(csr.Subject.CommonName) if ip := net.ParseIP(csr.Subject.CommonName); ip != nil {
subjectIsIP := ip != nil canonicalized.IPAddresses = append(canonicalized.IPAddresses, ip)
if subjectIsIP {
// nolint:gocritic
canonicalized.IPAddresses = append(csr.IPAddresses, ip)
} else { } else {
// nolint:gocritic canonicalized.DNSNames = append(canonicalized.DNSNames, csr.Subject.CommonName)
canonicalized.DNSNames = append(csr.DNSNames, csr.Subject.CommonName)
} }
} }
canonicalized.DNSNames = uniqueSortedLowerNames(csr.DNSNames) canonicalized.DNSNames = uniqueSortedLowerNames(canonicalized.DNSNames)
canonicalized.IPAddresses = uniqueSortedIPs(csr.IPAddresses) canonicalized.IPAddresses = uniqueSortedIPs(canonicalized.IPAddresses)
return canonicalized return canonicalized
} }