SSL Certification Expiry Date Checker


You want to automate checking expiry of SSL (HTTPS) Certificate expiry.



The link to the script is displayed in examples. It connects to the given site and shows site expiry. This can then be automated into a database, using some of my PHP or Perl Scripts, which can also be used to then report on sites about to expire.




Here is the code – but take note you may need the openssl client that supports proxying. Leave me a comment if you want this code.


[ $# -ne 1 ] &echo -n "$1 - "

echo "
GET / HTTP/1.0

" | openssl s_client -connect $1 2>&1 |
sed -n '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/p' |
openssl x509 -enddate |
awk -F= ' /notAfter/ { printf("Expires: %sn",$NF); } '

exit 0



[tags]openssl, SSL Certification Expiry Date Checker, Unix Coding School[/tags]


If you have found my website useful, please consider buying me a coffee below 😉

Leave a Reply

Your email address will not be published. Required fields are marked *