mirror of
https://github.com/FiloSottile/mkcert.git
synced 2025-10-14 00:41:40 +08:00
Add PKCS#12 generation with default password changeit
Merges #34 Fixes #20
This commit is contained in:

committed by
Filippo Valsorda

parent
53f1769ab5
commit
6be76ae477
11
Gopkg.lock
generated
11
Gopkg.lock
generated
@@ -34,9 +34,18 @@
|
||||
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
|
||||
version = "v0.3.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "software.sslmate.com/src/go-pkcs12"
|
||||
packages = [
|
||||
".",
|
||||
"internal/rc2"
|
||||
]
|
||||
revision = "2291e8f0f237e77e89ce233be7653ecca8cf391a"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "eb8c5336b6da0643bb04cf921e8e61c2966555c879bc20533b060724d71667c6"
|
||||
inputs-digest = "af41b15413cbd854c23022d16f6da65af1235c9510e4193a17efef737de71c70"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
@@ -36,3 +36,7 @@
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/net"
|
||||
|
||||
[[constraint]]
|
||||
name = "software.sslmate.com/src/go-pkcs12"
|
||||
branch = "master"
|
9
cert.go
9
cert.go
@@ -21,6 +21,7 @@ import (
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"software.sslmate.com/src/go-pkcs12"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -91,6 +92,12 @@ func (m *mkcert) makeCert(hosts []string) {
|
||||
&pem.Block{Type: "CERTIFICATE", Bytes: cert}), 0644)
|
||||
fatalIfErr(err, "failed to save certificate key")
|
||||
|
||||
// generate PKCS#12
|
||||
domainCert, _ := x509.ParseCertificate(cert)
|
||||
pfxData, _ := pkcs12.Encode(rand.Reader, priv, domainCert, []*x509.Certificate{m.caCert}, "changeit")
|
||||
err = ioutil.WriteFile(filename+".p12", pfxData, 0644)
|
||||
fatalIfErr(err, "failed to save PKCS#12")
|
||||
|
||||
secondLvlWildcardRegexp := regexp.MustCompile(`(?i)^\*\.[0-9a-z_-]+$`)
|
||||
log.Printf("\nCreated a new certificate valid for the following names 📜")
|
||||
for _, h := range hosts {
|
||||
@@ -99,7 +106,7 @@ func (m *mkcert) makeCert(hosts []string) {
|
||||
log.Printf(" Warning: many browsers don't support second-level wildcards like %q ⚠️", h)
|
||||
}
|
||||
}
|
||||
log.Printf("\nThe certificate is at \"./%s.pem\" and the key at \"./%s-key.pem\" ✅\n\n", filename, filename)
|
||||
log.Printf("\nThe certificate is at \"./%s.pem\", and the key at \"./%s-key.pem\", and the PKCS#12 at \"./%s.p12\" ✅\n\n", filename, filename, filename)
|
||||
}
|
||||
|
||||
// loadCA will load or create the CA at CAROOT.
|
||||
|
Reference in New Issue
Block a user