Last active
May 3, 2017 13:46
-
-
Save solarmicrobe/641889b51e9b503175354bc30d6b7703 to your computer and use it in GitHub Desktop.
Determine if SSL cert is about to expire
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
#!/usr/bin/env sh | |
# http://stackoverflow.com/questions/21297853/how-to-determine-ssl-cert-expiration-date-from-a-pem-encoded-certificate | |
# Usage: is_cert_expiring.sh [/path/to/cert/file.pem [seconds]] | |
1=${1:file.pem} # File path | |
2=${2:-86400} # Seconds to expiry | |
if openssl x509 -checkend $2 -noout -in $1; then | |
echo "Certificate is good for another day!" | |
else | |
echo "Certificate has expired or will do so within 24 hours!" | |
echo "(or is invalid/not found)" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment