brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: openssl s_client shows when a site's certificate expires

Openssl
~/tips/openssl-expiry

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

Prints the start and end date of a website's TLS certificate from the terminal.

A certificate that quietly expires is one of the most avoidable outages I know of. You can check any HTTPS site from the terminal in one line.

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

It prints notBefore and notAfter, the period the certificate is valid. -servername matters: without it a server with several sites can hand you the certificate of a different one.

For a script, add -checkend 604800 to the x509 part. It exits with an error when the certificate expires within the next 7 days (604800 seconds), so a cron job can warn you.

Caveat: this checks the certificate the server presents on that port, not what a reverse proxy in front of it might serve on another one.

Further reading: openssl s_client

Going deeper: Run degoog on Unraid as your own search page, compared with SearXNG and 4get

More Openssl tips openssl s_client -connect 203.0.113.10:443 -servername example.com </dev/null | openssl x509 -noout -subject openssl x509 -in cert.pem -days 365 -signkey key.pem -out cert-new.pem printf %s hello | openssl dgst -sha256 -hmac secret openssl pkcs12 -legacy -in old.pfx -nokeys echo 'aGVsbG8gd29ybGQ=' | openssl base64 -d All Openssl tips (34) All topics

Link