Add support for client certificates with -client

Fixes #125
Closes #89
This commit is contained in:
John Downey
2019-02-02 15:44:12 -05:00
committed by Filippo Valsorda
parent 5bb0c47df7
commit 66af5a51f6
3 changed files with 12 additions and 2 deletions

View File

@@ -125,6 +125,9 @@ mkcert supports the following root stores:
-cert-file FILE, -key-file FILE, -p12-file FILE
Customize the output paths.
-client
Generate a certificate for client authentication.
-ecdsa
Generate a certificate with an ECDSA key.

View File

@@ -76,6 +76,9 @@ func (m *mkcert) makeCert(hosts []string) {
tpl.DNSNames = append(tpl.DNSNames, h)
}
}
if m.client {
tpl.ExtKeyUsage = []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}
}
// IIS (the main target of PKCS #12 files), only shows the deprecated
// Common Name in the UI. See issue #115.

View File

@@ -44,6 +44,9 @@ const advancedUsage = `Advanced options:
-cert-file FILE, -key-file FILE, -p12-file FILE
Customize the output paths.
-client
Generate a certificate for client authentication.
-ecdsa
Generate a certificate with an ECDSA key.
@@ -67,6 +70,7 @@ func main() {
uninstallFlag = flag.Bool("uninstall", false, "")
pkcs12Flag = flag.Bool("pkcs12", false, "")
ecdsaFlag = flag.Bool("ecdsa", false, "")
clientFlag = flag.Bool("client", false, "")
helpFlag = flag.Bool("help", false, "")
carootFlag = flag.Bool("CAROOT", false, "")
certFileFlag = flag.String("cert-file", "", "")
@@ -95,7 +99,7 @@ func main() {
}
(&mkcert{
installMode: *installFlag, uninstallMode: *uninstallFlag,
pkcs12: *pkcs12Flag, ecdsa: *ecdsaFlag,
pkcs12: *pkcs12Flag, ecdsa: *ecdsaFlag, client: *clientFlag,
certFile: *certFileFlag, keyFile: *keyFileFlag, p12File: *p12FileFlag,
}).Run(flag.Args())
}
@@ -105,7 +109,7 @@ const rootKeyName = "rootCA-key.pem"
type mkcert struct {
installMode, uninstallMode bool
pkcs12, ecdsa bool
pkcs12, ecdsa, client bool
keyFile, certFile, p12File string
CAROOT string