Skip to content

Commit

Permalink
Drop Apple 825-days rule bypass, shorten and print expiration
Browse files Browse the repository at this point in the history
Closes #299
Closes #271
  • Loading branch information
FiloSottile committed Oct 25, 2020
1 parent 1ad7f56 commit 167867a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,20 @@ func (m *mkcert) makeCert(hosts []string) {
fatalIfErr(err, "failed to generate certificate key")
pub := priv.(crypto.Signer).Public()

// Certificates last for 2 years and 3 months, which is always less than
// 825 days, the limit that macOS/iOS apply to all certificates,
// including custom roots. See https://support.apple.com/en-us/HT210176.
expiration := time.Now().AddDate(2, 3, 0)

tpl := &x509.Certificate{
SerialNumber: randomSerialNumber(),
Subject: pkix.Name{
Organization: []string{"mkcert development certificate"},
OrganizationalUnit: []string{userAndHostname},
},

NotAfter: time.Now().AddDate(10, 0, 0),

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

KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature,
BasicConstraintsValid: true,
Expand Down Expand Up @@ -134,6 +133,8 @@ func (m *mkcert) makeCert(hosts []string) {
log.Printf("\nThe PKCS#12 bundle is at \"%s\"\n", p12File)
log.Printf("\nThe legacy PKCS#12 encryption password is the often hardcoded default \"changeit\" ℹ️\n\n")
}

log.Printf("It will expire on %s 🗓\n\n", expiration.Format("2 January 2006"))
}

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

0 comments on commit 167867a

Please sign in to comment.