Last active
December 17, 2015 18:49
-
-
Save henrik242/5655890 to your computer and use it in GitHub Desktop.
Checks for upcoming expiry of SSL certificates, e.g. HTTPS or LDAPS. Useful for cron jobs and server monitoring.
This file contains 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
#!/bin/bash | |
SERVER=my.example.com:443 | |
WARNDAYS=30 | |
EXPIRE=$(openssl s_client -connect $SERVER 2>/dev/null </dev/null | openssl x509 -noout -enddate | cut -d= -f2) | |
DAYS=$((( $(date --date "${EXPIRE}" +%s) - $(date +%s) ) / 86400)); | |
[ $DAYS -lt $WARNDAYS ] && echo "WARNING: SSL certificate for $SERVER expires in $DAYS days" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment