Created
October 19, 2014 12:49
-
-
Save reox/17b7ee632b6bb8b45081 to your computer and use it in GitHub Desktop.
Print out information about non valid certificates and certificates that will run out in less than 30 days.
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 | |
# Show the validity of certificate files | |
# If the certificate will run out in less than one month, a warning is shown | |
# If the certificate is not valid anymore, an error message is shown | |
# Valid certificates are not printed out | |
for cert in /etc/nginx/ssl/*.crt; do | |
d1=$(date -d "$(openssl x509 -noout -dates -in $cert | grep notAfter | cut -d '=' -f 2)" +%s) | |
d2=$(date +%s) | |
valid=$(( (d1 - d2) / 86400 )) | |
if [ $valid -le 0 ]; then | |
echo "[ERRO] $cert is NOT VALID anymore! (since $(( $valid * -1)) days)" | |
elif [ $valid -le 30 ]; then | |
echo "[WARN] $cert will be run out in less than one month! ($valid days left)" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment