Problem
You want to automate checking expiry of SSL (HTTPS) Certificate expiry.
Solution
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.
Example
./openssl_cert_expiry_check www.example.com:443
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.
#!/bin/bash
[ $# -ne 1 ] &echo -n "$1 - "
echo "
GET / HTTP/1.0
EOT
" | 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
Reference
[tags]openssl, SSL Certification Expiry Date Checker, Unix Coding School[/tags]