Checking SSL Expiry Dates

TIL: How to check a remote SSL certificate for it’s expiry date:

openssl s_client -servername <NAME> -connect <HOST:PORT> 2>/dev/null | openssl x509 -noout -dates

e.g.

$ openssl s_client -servername michaelvigor.dev -connect michaelvigor.dev:443 2>/dev/null | openssl x509 -noout -dates
notBefore=Jul  5 00:00:00 2020 GMT
notAfter=Jul  5 12:00:00 2021 GMT

Or checking a local pem file directly:

openssl x509 -enddate -noout -in  <FILE>.pem