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 x509 -checkend returns an exit code for expiry, a security check for cron

Security
~/tips/tip-security-openssl-x509-checkend-cron

openssl x509 -in /etc/ssl/site/fullchain.pem -noout -checkend 1209600

Tests whether a certificate file expires within a chosen time and signals it with the exit code.

Reading expiry dates by eye does not scale. openssl can answer with an exit code instead.

openssl x509 -in /etc/ssl/site/fullchain.pem -noout -checkend 1209600
echo $?

-checkend 1209600 asks whether the certificate is still valid 1209600 seconds (14 days) from now. The exit code is 0 if it is, and 1 if the certificate will have expired by then. It also prints a sentence you can ignore in scripts.

Put it in a cron job and send a message on exit code 1. For a file with a whole chain, openssl only looks at the first certificate, which is normally your own site certificate.

Further reading: openssl x509 manual page

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

More Security tips tcpdump -nn -r capture.pcap port 53 mkcert -install Strict-Transport-Security: max-age=0 Referrer-Policy: strict-origin-when-cross-origin wp super-admin list All Security tips (79) All topics

Link