Last active
October 20, 2023 17:37
-
-
Save Sean-Bradley/7826495e54f52865dd1d0af14a6570ea to your computer and use it in GitHub Desktop.
A script to return the number of days before a SSL certificate expires. Visit https://sbcode.net/zabbix/system-run/ for instructions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data=`echo | openssl s_client -servername $1 -connect $1:443 2>/dev/null | openssl x509 -noout -enddate | sed -e 's#notAfter=##'` | |
ssldate=`date -d "${data}" '+%s'` | |
nowdate=`date '+%s'` | |
diff="$((${ssldate}-${nowdate}))" | |
echo $((${diff}/86400)) |
Thanks, works like a charm.
Particularly useful if we have some protected hosts and public check of SSL expiration is not possible. Script is doing it locally on own host, nice.
All the best
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
missing
or " " on data, ssldate & nowdate.