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
| Word | What it means |
|---|---|
| Lifetime | the time from notBefore to notAfter |
| Renewal point | the moment a client should renew |
| Jitter | a small spread so clients do not all renew at once |
| ARI | ACME Renewal Information, a window suggested by the CA |
| Renewal window | a 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
docker exec python python3 steps/renew.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
What the Run prints
| Lifetime | Days | Renew on day | Renewals a year |
|---|---|---|---|
| before 2026 | 398 | 265.3 | 1.4 |
| from March 2026 | 200 | 133.3 | 2.7 |
| from March 2027 | 100 | 66.7 | 5.5 |
| from March 2029 | 47 | 31.3 | 11.6 |
| this lab, 24 h | 1 | 0.7 | 547.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?
docker exec client step certificate needs-renewal https://shop --roots /ca/certs/root_ca.crt --verboseShown here, not run. Press Start lab to type it into your own lab’s terminal.
Does it end within 25 hours?
docker exec client step certificate needs-renewal https://shop --roots /ca/certs/root_ca.crt --expires-in 25h --verboseShown 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
docker exec python python3 steps/ari.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
What the ARI model prints
| Line | What it means |
|---|---|
| certificate id: aYhba4dGPMjh3hpajywPm21-SiE.BKGyw9Tl9gcY | Key id and serial, each in base64url |
| window 2029-05-21 00:00 UTC to 2029-05-23 00:00 UTC | The CA's suggestion |
| renew at: 2029-05-22 09:59 UTC | A 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.