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

Category: Web Servers & Proxies

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

Check a certificate's expiry date over the network

s_client connects to the TLS port and fetches the certificate, and the leading echo | feeds a newline so the connection closes immediately instead of hanging. x509 -noout -enddate then prints just the Not After date. Compare it with today's date to see how much time is left.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.