浏览代码

Set the CommonName when generating PKCS#12 files

Fixes #115
Filippo Valsorda 6 年之前
父节点
当前提交
50b8c9f09f
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      cert.go

+ 7 - 1
cert.go

@@ -25,7 +25,7 @@ import (
 	"strings"
 	"time"
 
-	"software.sslmate.com/src/go-pkcs12"
+	pkcs12 "software.sslmate.com/src/go-pkcs12"
 )
 
 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
 	cert, err := x509.CreateCertificate(rand.Reader, tpl, m.caCert, &pub, m.caKey)
 	fatalIfErr(err, "failed to generate certificate")