Skip to content

Commit 167867a

Browse files
committed
Drop Apple 825-days rule bypass, shorten and print expiration
Closes #299 Closes #271
1 parent 1ad7f56 commit 167867a

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

cert.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,20 @@ func (m *mkcert) makeCert(hosts []string) {
5656
fatalIfErr(err, "failed to generate certificate key")
5757
pub := priv.(crypto.Signer).Public()
5858

59+
// Certificates last for 2 years and 3 months, which is always less than
60+
// 825 days, the limit that macOS/iOS apply to all certificates,
61+
// including custom roots. See https://support.apple.com/en-us/HT210176.
62+
expiration := time.Now().AddDate(2, 3, 0)
63+
5964
tpl := &x509.Certificate{
6065
SerialNumber: randomSerialNumber(),
6166
Subject: pkix.Name{
6267
Organization: []string{"mkcert development certificate"},
6368
OrganizationalUnit: []string{userAndHostname},
6469
},
6570

66-
NotAfter: time.Now().AddDate(10, 0, 0),
67-
68-
// Fix the notBefore to temporarily bypass macOS Catalina's limit on
69-
// certificate lifespan. Once mkcert provides an ACME server, automation
70-
// will be the recommended way to guarantee uninterrupted functionality,
71-
// and the lifespan will be shortened to 825 days. See issue 174 and
72-
// https://support.apple.com/en-us/HT210176.
73-
NotBefore: time.Date(2019, time.June, 1, 0, 0, 0, 0, time.UTC),
71+
NotAfter: expiration,
72+
NotBefore: time.Now(),
7473

7574
KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,
7675
BasicConstraintsValid: true,
@@ -134,6 +133,8 @@ func (m *mkcert) makeCert(hosts []string) {
134133
log.Printf("\nThe PKCS#12 bundle is at \"%s\"\n", p12File)
135134
log.Printf("\nThe legacy PKCS#12 encryption password is the often hardcoded default \"changeit\" ℹ️\n\n")
136135
}
136+
137+
log.Printf("It will expire on %s 🗓\n\n", expiration.Format("2 January 2006"))
137138
}
138139

139140
func (m *mkcert) printHosts(hosts []string) {

0 commit comments

Comments
 (0)