Skip to main content

How to check when an HTTPS certificate expires

You can check whether a certificate is about to expire using the following openssl command:

openssl s_client -connect </dev/null 2>/dev/null \
  | openssl x509 -checkend "$SECONDS"

This will exit with status 0 if the certificate won’t expire before $SECONDS have passed, and status 1 if it will.

Alternatives considered