SSL certificate expired? How to check, fix and get warned early

When a certificate expires, browsers show a full-page warning instead of your site. Here is how to confirm the date, find out why renewal failed, and get a warning before the next expiry.

Updated

Short answer

Check the dates the server really sends with openssl s_client, then work out why renewal failed: the renewal job is not running, the challenge is blocked, or the server never loaded the new certificate. To avoid a repeat, monitor the expiry date and get warned weeks ahead.

Get SSL expiry warnings free

What you see when a certificate expires

Browsers refuse the connection and show a warning page. Chrome and other Chromium browsers label it NET::ERR_CERT_DATE_INVALID. The site is still running. Visitors just cannot get past the warning, and API clients fail the TLS handshake with an error about an expired certificate.

Before you fix anything, check that the clock is not the problem. A device with a wrong date shows the same error for a valid certificate. If the error appears on every device, the certificate is the cause.

Check the expiry date

Ask the server itself, not the certificate file on disk. The two differ when a renewed certificate was never loaded.

Show the dates the server sendsShell
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
  | openssl x509 -noout -dates

The output has notBefore and notAfter lines. If notAfter is in the past, the server is still serving the old certificate. To test a certificate for a script or cron job, -checkend exits non-zero if it expires within the given number of seconds:

Fail if the certificate expires within 14 daysShell
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
  | openssl x509 -noout -checkend 1209600

If you use Certbot, certbot certificates lists each certificate it manages with its domains and expiry date. Compare that with what the server sends. A newer date on disk than on the wire means the server needs a reload.

Why auto-renewal fails

Let's Encrypt certificates are valid for 90 days, and the recommendation is to renew every 60. That leaves about a month of retries before expiry, so a certificate that expires has usually been failing to renew for weeks without anyone noticing.

CauseHow to checkFix
Renewal job not runningLook for certbot renew in the crontab, or run systemctl list-timersRe-enable the timer or add a cron entry that runs certbot renew twice a day
Challenge blockedRun certbot renew --dry-run and read the errorHTTP-01 validation uses port 80 only. Open port 80 in the firewall and security group, and make sure redirects end on port 80 or 443
DNS points elsewheredig +short example.com returns an address that is not your serverPoint the record back, or move renewal to the new server. Validation fetches the file from whatever the name resolves to
Renewed but not reloadedThe dates on disk are new, the dates from openssl s_client are oldReload the web server after renewal, ideally with a deploy hook
Intermediate certificate missingopenssl s_client -showcerts shows only one certificateConfigure the server to send the certificate together with its intermediates
Several servers behind one nameOnly some requests fail, or the old date appears intermittentlyThe validation file must be reachable on every server behind the name. Renew in one place and copy the result to all of them

The "renewed but not reloaded" case is easy to miss, because the renewal itself worked. A web server reads the certificate at start or reload, so the old one stays in memory. Certbot can run a command only after a successful renewal:

Reload nginx after each successful renewalShell
certbot renew --deploy-hook "systemctl reload nginx"

You can also put an executable script in /etc/letsencrypt/renewal-hooks/deploy, and Certbot runs it after every successful renewal.

Fix an expired certificate now

  1. Run certbot renew --dry-run and read the first error. It points at the cause from the table above.
  2. Fix that cause, then run certbot renew. Add --force-renewal only if Certbot says the certificate is not due yet.
  3. Reload the web server, or let the deploy hook do it.
  4. Re-run the openssl s_client command and confirm notAfter is in the future.
  5. Test the intermediate chain from outside your network, since your own browser may have cached intermediates.

If your host or CDN manages the certificate, renewal happens on their side. Check the domain validation status in their dashboard. A failing DNS record or a recently moved domain is the usual blocker there too.

Set it up in UptimeIO

SSL and domain expiry are checks on an HTTP monitor, not a separate monitor type. Add an HTTP or HTTPS monitor for your site, then turn on the options under SSL, domain & performance alerts. Domain expiry warnings need Pro or Scale; SSL warnings are on every plan.

  1. Create an HTTP monitor with your https:// URL.
  2. Turn on SSL Certificate Monitoring and keep Check Certificate Expiry on.
  3. Select the warning thresholds you want.
  4. Choose where alerts go: email, Slack, Telegram, Pushover or a webhook.
  • Thresholds: warnings 30, 15, 7 and 1 days before expiry. Select at least one. The default is 7 and 1.
  • Warnings: sent to the monitor's alert channels without opening an incident, because the site is still up.
  • Already expired or invalid: with Check Certificate Validity on, an expired, self-signed or otherwise invalid certificate opens an incident, which resolves once a valid certificate is served.
  • Plans: included on every plan, including Free.

Pick the 30-day threshold if you want time to fix a broken renewal. With renewal every 60 days, a 90-day certificate is replaced when about 30 days remain, so a 30-day warning means renewal has stopped working.

Questions

What does NET::ERR_CERT_DATE_INVALID mean?
The certificate the server sent has expired or is not yet valid. If it happens on every device, check the certificate dates with openssl s_client. If it happens on one device, check that device's clock.
How do I check when an SSL certificate expires?
Run echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -dates. The notAfter line is the expiry date of the certificate the server is serving.
Why did Let's Encrypt not renew my certificate?
Common causes are a renewal timer that is not running, port 80 blocked for the HTTP-01 challenge, a domain that no longer points at the server, or a web server that was never reloaded after renewal. Run certbot renew --dry-run to see the error.
How long is a Let's Encrypt certificate valid?
Default certificates are valid for 90 days. Let's Encrypt recommends renewing every 60 days.
Does UptimeIO warn me before a certificate expires?
Yes. HTTP monitors can send warnings 30, 15, 7 and 1 days before expiry, on every plan including Free. An expired or invalid certificate opens an incident.

Related

Start monitoring in a few minutes

Start monitoring free

Free plan · 50 monitors · No credit card required