From e23a7c3f98223795508396a095ccbeb1de29c1d0 Mon Sep 17 00:00:00 2001 From: vzlcn0 <[email protected]> Date: Thu, 20 Aug 2020 17:25:40 -0700 Subject: [PATCH] Support SAN for Go 1.15+ Starting from Go 1.15+ Certificate without subjectAltName will fail with error: "x509: certificate relies on legacy Common Name field" More info: https://github.com/golang/go/issues/39568 This is only for Domain name and does not support IP Address: https://godoc.org/crypto/x509#Certificate --- cert.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cert.go b/cert.go index 4ec82dd..8533368 100644 --- a/cert.go +++ b/cert.go @@ -89,6 +89,7 @@ func GenerateCertificateKey(commonName string, isCA bool, parent *x509.Certifica NotAfter: notAfter, KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature, ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, + DNSNames: []string{commonName}, } if isCA {