Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,17 @@ func (m *mkcert) loadCA() {
keyPEMBlock, err := ioutil.ReadFile(filepath.Join(m.CAROOT, rootKeyName))
fatalIfErr(err, "failed to read the CA key")
keyDERBlock, _ := pem.Decode(keyPEMBlock)
if keyDERBlock == nil || keyDERBlock.Type != "PRIVATE KEY" {
if keyDERBlock == nil || keyDERBlock.Type != "PRIVATE KEY" && keyDERBlock.Type != "RSA PRIVATE KEY" && keyDERBlock.Type != "EC PRIVATE KEY" {
log.Fatalln("ERROR: failed to read the CA key: unexpected content")
}
m.caKey, err = x509.ParsePKCS8PrivateKey(keyDERBlock.Bytes)
switch keyDERBlock.Type {
case "RSA PRIVATE KEY":
m.caKey, err = x509.ParsePKCS1PrivateKey(keyDERBlock.Bytes)
case "EC PRIVATE KEY":
m.caKey, err = x509.ParseECPrivateKey(keyDERBlock.Bytes)
default:
m.caKey, err = x509.ParsePKCS8PrivateKey(keyDERBlock.Bytes)
}
fatalIfErr(err, "failed to parse the CA key")
}

Expand Down