Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

When to renew a certificate

After this lesson: I can work out when a certificate should be renewed from its lifetime and a CA's renewal window.

70 min lesson4 commandsCertificate automation lab: ACME, short-lived TLS certificates and automatic renewal with a private CA

Renew too late and the site goes dark

Certificate renewal timing is the rule that decides when a client asks for a new certificate. Renew too late and one slow CA or one failed challenge leaves the site with an expired certificate.

Renew too early and you waste the lifetime. At 47 days there is little room for either.

By the end of this lesson

Note

I can work out when a certificate should be renewed from its lifetime and a CA's renewal window.

Key words

WordWhat it means
Lifetimethe time from notBefore to notAfter
Renewal pointthe moment a client should renew
Jittera small spread so clients do not all renew at once
ARIACME Renewal Information, a window suggested by the CA
Renewal windowa start and an end to renew between

The cells students fill in are left blank in this preview.

Renew when two thirds has passed

A common rule is to renew once two thirds of the lifetime has passed. A 90-day certificate renews at day 60, leaving 30 days to fix a failure.

The rule scales with the lifetime. A 47-day certificate renews at about day 31, leaving about 16 days. A 24-hour one renews after 16 hours.

Renewal points for each lifetime

Command
docker exec python python3 steps/renew.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

What the Run prints

LifetimeDaysRenew on dayRenewals a year
before 2026398265.31.4
from March 2026200133.32.7
from March 202710066.75.5
from March 20294731.311.6
this lab, 24 h10.7547.5

The cells students fill in are left blank in this preview.

The step client asks the same question

step certificate needs-renewal answers yes once two thirds of the lifetime has passed, and no before that. The flag --expires-in asks instead whether the certificate ends within a given time.

The next two Runs ask about the shop's live certificate. It is fresh, so the first says no. It ends within 25 hours, so the second says yes.

Does the shop need renewing now?

Command
docker exec client step certificate needs-renewal https://shop --roots /ca/certs/root_ca.crt --verbose

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Does it end within 25 hours?

Command
docker exec client step certificate needs-renewal https://shop --roots /ca/certs/root_ca.crt --expires-in 25h --verbose

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

What the two checks printed

The first printed certificate does not need renewal, the second certificate needs renewal. The shop renews itself: its web server checks on a timer and renews well before the end, with no person involved.

Jitter spreads the load

If a thousand servers got certificates at the same moment, the two-thirds rule sends them all back at the same moment too. The CA sees a spike and some requests fail.

Jitter moves each renewal a little, by a random or per-server amount. The Run's five servers with 47-day certificates renew between day 30.31 and day 30.65.

ARI lets the CA choose the window

ACME Renewal Information, RFC 9773, lets a CA suggest a window to renew in. The client names each certificate by an id made from the issuer's key id and the serial number. It then picks a random moment inside the window.

If the CA must replace certificates early, it moves the window. A window already passed means renew now.

Pick a moment in a renewal window

Command
docker exec python python3 steps/ari.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

What the ARI model prints

LineWhat it means
certificate id: aYhba4dGPMjh3hpajywPm21-SiE.BKGyw9Tl9gcYKey id and serial, each in base64url
window 2029-05-21 00:00 UTC to 2029-05-23 00:00 UTCThe CA's suggestion
renew at: 2029-05-22 09:59 UTCA random moment inside it, from a fixed seed
renew at: 2029-05-01 09:00 UTC (the window has passed, so renew now)The CA moved the window into the past

The cells students fill in are left blank in this preview.

A common mistake

Warning

Many people think the safest moment to renew is just before expiry, to use every day. One failed attempt then leaves no time to fix it. Renew at two thirds, or inside the CA's window, and keep a third in reserve.

About this lab and its source: Certificate automation lab: ACME, short-lived TLS certificates and automatic renewal with a private CA

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.