Set the CommonName when generating PKCS#12 files

Fixes #115
This commit is contained in:
Filippo Valsorda
2019-02-02 14:45:36 -05:00
parent 3bcdd3721c
commit 50b8c9f09f

View File

@@ -25,7 +25,7 @@ import (
"strings" "strings"
"time" "time"
"software.sslmate.com/src/go-pkcs12" pkcs12 "software.sslmate.com/src/go-pkcs12"
) )
var userAndHostname string var userAndHostname string
@@ -73,6 +73,12 @@ func (m *mkcert) makeCert(hosts []string) {
} }
} }
// IIS (the main target of PKCS #12 files), only shows the deprecated
// Common Name in the UI. See issue #115.
if m.pkcs12 {
tpl.Subject.CommonName = hosts[0]
}
pub := priv.PublicKey pub := priv.PublicKey
cert, err := x509.CreateCertificate(rand.Reader, tpl, m.caCert, &pub, m.caKey) cert, err := x509.CreateCertificate(rand.Reader, tpl, m.caCert, &pub, m.caKey)
fatalIfErr(err, "failed to generate certificate") fatalIfErr(err, "failed to generate certificate")