How to check when an SSL certificate expires

Find the expiry date of an SSL/TLS certificate from the browser padlock, with openssl on the command line, or by decoding the PEM file.

Updated 2026-12-01. Tool: Certificate Decoder

The short answer

Every certificate carries a notAfter date, the moment it stops being valid. For a live site, read it in the browser's certificate viewer or run openssl s_client piped into openssl x509 -noout -enddate. For a certificate file, run openssl x509 -in cert.pem -noout -enddate or paste the file into a certificate decoder.

In the browser

Click the icon to the left of the address bar, open the connection or certificate details, and the certificate viewer lists the validity period as "Valid to" or "Expires on". The wording differs between browsers, but each shows the site's own certificate first, with the issuing certificates in a separate tab or list.

With openssl, for a live site

echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
  | openssl x509 -noout -enddate

which prints a line such as:

notAfter=Feb 22 23:53:08 2027 GMT
  • -servername sends the host name (SNI), so a server that hosts several sites returns the right certificate. Recent OpenSSL takes it from -connect, but stating it also works with older versions and with LibreSSL, which macOS ships as openssl.
  • echo | closes the connection straight away instead of waiting for input.
  • Use -dates instead of -enddate for both the start and end dates, and add -subject -issuer to see which certificate you are looking at.
  • For a mail server or another protocol that upgrades with STARTTLS, add for example -starttls smtp and use that service's port.

-checkend turns this into a check for scripts. It takes a number of seconds and exits with status 1 if the certificate will have expired by then:

echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null \
  | openssl x509 -noout -checkend 2592000 || echo "Expires within 30 days"

curl prints the dates too in its verbose output, with most TLS back ends:

curl -sv -o /dev/null https://example.com 2>&1 | grep -E 'start date|expire date'

For a certificate file

openssl x509 -in cert.pem -noout -enddate

Add -inform der for a binary DER file, often named .der or .cer. openssl x509 reads only the first certificate in a file, so for a chain file such as fullchain.pem it shows the leaf, the certificate issued for your site.

What to watch for

  • Leaf and chain: a server sends its own certificate and usually one or more intermediates. An expired intermediate breaks connections just as an expired leaf does. Add -showcerts to s_client to print every certificate the server sends, and check each.
  • Time zone: notAfter is in UTC (shown as GMT by openssl), so a certificate can expire on what is still the previous evening where you are.
  • Several servers: behind a load balancer or CDN, different addresses can serve different certificates. A renewed certificate on one does not mean every one has been updated.
  • Valid is not trusted: a date inside the validity period says nothing about whether the certificate is trusted or revoked. openssl s_client reports a "Verify return code" for the chain.
  • Short lifetimes: certificates from automated authorities last a few months or less and are meant to renew on their own, so monitor the renewal job as well as the date.

Do it in your browser

The Certificate Decoder reads a PEM or DER certificate you paste or open and shows Valid from and Valid until in UTC, with a line giving the days remaining or the days since it expired. Paste a whole chain and each certificate is decoded in order. It cannot connect to a site, so fetch the certificate first with openssl s_client -showcerts or export it from the browser's certificate viewer. It does not verify the signature, the chain or revocation. Nothing you paste is uploaded.

Frequently asked questions

How do I check an SSL certificate expiry date from the command line?
Run echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -enddate. The notAfter line is the expiry date in UTC.
What happens when an SSL certificate expires?
Browsers show a full-page warning and most API clients refuse to connect, so the site is effectively down for visitors. Nothing changes on the server; the certificate simply fails validation until it is replaced.
How do I check certificate expiry in a script?
Use openssl x509 -noout -checkend with a number of seconds. It exits with status 0 if the certificate is still valid at that point and 1 if it will have expired, which a cron job or monitoring check can act on.
Does the intermediate certificate’s expiry matter?
Yes. Clients check the chain the server sends, so an expired intermediate can break connections just as an expired leaf does. Check every certificate the server sends, not only the first.