Skip to content

Instantly share code, notes, and snippets.

@solarmicrobe
Last active May 3, 2017 13:46
Show Gist options
  • Save solarmicrobe/641889b51e9b503175354bc30d6b7703 to your computer and use it in GitHub Desktop.
Save solarmicrobe/641889b51e9b503175354bc30d6b7703 to your computer and use it in GitHub Desktop.
Determine if SSL cert is about to expire
#!/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