mirror of
https://github.com/FiloSottile/mkcert.git
synced 2025-10-14 00:41:40 +08:00
5
cert.go
5
cert.go
@@ -12,6 +12,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -74,9 +75,13 @@ func (m *mkcert) makeCert(hosts []string) {
|
|||||||
&pem.Block{Type: "CERTIFICATE", Bytes: cert}), 0644)
|
&pem.Block{Type: "CERTIFICATE", Bytes: cert}), 0644)
|
||||||
fatalIfErr(err, "failed to save certificate key")
|
fatalIfErr(err, "failed to save certificate key")
|
||||||
|
|
||||||
|
secondLvlWildcardRegexp := regexp.MustCompile(`(?i)^\*\.[0-9a-z_-]+$`)
|
||||||
log.Printf("\nCreated a new certificate valid for the following names 📜")
|
log.Printf("\nCreated a new certificate valid for the following names 📜")
|
||||||
for _, h := range hosts {
|
for _, h := range hosts {
|
||||||
log.Printf(" - %q", h)
|
log.Printf(" - %q", h)
|
||||||
|
if secondLvlWildcardRegexp.MatchString(h) {
|
||||||
|
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\" ✅\n\n", filename, filename)
|
||||||
}
|
}
|
||||||
|
5
main.go
5
main.go
@@ -113,11 +113,10 @@ Change the CA certificate and key storage location by setting $CAROOT.
|
|||||||
log.Fatalf("ERROR: %q is not a valid hostname or IP: %s", name, err)
|
log.Fatalf("ERROR: %q is not a valid hostname or IP: %s", name, err)
|
||||||
}
|
}
|
||||||
args[i] = punycode
|
args[i] = punycode
|
||||||
if hostnameRegexp.MatchString(punycode) {
|
if !hostnameRegexp.MatchString(punycode) {
|
||||||
continue
|
|
||||||
}
|
|
||||||
log.Fatalf("ERROR: %q is not a valid hostname or IP", name)
|
log.Fatalf("ERROR: %q is not a valid hostname or IP", name)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m.makeCert(args)
|
m.makeCert(args)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user