1
0
mirror of https://tildegit.org/solderpunk/gemcert synced 2024-11-23 00:32:08 +01:00

Add domain wildcard to CN and SAN on server certs.

This commit is contained in:
Solderpunk 2020-07-09 11:27:22 +02:00
parent 8f8f583b97
commit 4fd7d4d9be

11
main.go

@ -81,7 +81,13 @@ func main() {
}
func getServerCertTemplate(domain string, notBefore time.Time, notAfter time.Time) x509.Certificate {
return getCommonCertTemplate(notBefore, notAfter)
wildcard := "*." + domain
template := getCommonCertTemplate(notBefore, notAfter)
template.Subject = pkix.Name{
CommonName: wildcard,
}
template.DNSNames = append(template.DNSNames, wildcard)
return template
}
func getClientCertTemplate(domain string, notBefore time.Time, notAfter time.Time) x509.Certificate {
@ -96,9 +102,6 @@ func getCommonCertTemplate(notBefore time.Time, notAfter time.Time) x509.Certifi
}
template := x509.Certificate{
SerialNumber: serialNumber,
Subject: pkix.Name{
Organization: []string{"Acme Co"},
},
NotBefore: notBefore,
NotAfter: notAfter,
}