-
-
Save romanrm/bb95e209c4a75efc32b0e5d46d0881e8 to your computer and use it in GitHub Desktop.
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 | |
# Automated revocation check for SSL certificates (*.pem) | |
CERTDIR=/YOUR_PEMFILES_DIR/ | |
TMPFILE=/tmp/checkrevoke.tmp | |
if [ "$1" == "-v" ]; then | |
VERBOSE=1 | |
fi | |
cd $CERTDIR || ((echo Failed to cd to the cert directory!; exit 1)) | |
for F in `find . -maxdepth 1 -type f | cut -d / -f 2 | grep -v -e chain\.pem -e \.sh$`; do | |
if [ "$VERBOSE" == "1" ]; then echo Checking $F...; fi | |
URL=`openssl x509 -noout -ocsp_uri -in $F` | |
HOST=`echo $URL | cut -d / -f 3` | |
CMD="openssl ocsp -issuer chain.pem -cert $F -text -url $URL -header HOST=$HOST" | |
if [ "$VERBOSE" == "1" ]; then echo $CMD; fi | |
RESP=`$CMD > $TMPFILE 2>&1` | |
if [ "$VERBOSE" == "1" ]; then cat $TMPFILE; fi | |
if [ "`grep \"$F: good\" $TMPFILE`" == "" ]; then | |
echo $F seems to be revoked! | |
fi | |
done | |
rm $TMPFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also need to have chain.pem in there with (for GlobalSign):