Created
November 10, 2011 01:01
-
-
Save smeghead/1353751 to your computer and use it in GitHub Desktop.
check ssl cert 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
#!/bin/sh | |
if [ $# == 0 ]; then | |
echo "usage: $1 <ssl cert file>" | |
exit 1 | |
fi | |
FILENAME=$1 | |
if [ ! -f "$FILENAME" ]; then | |
echo "ERROR: <ssl cert file> not exists. $FILENAME" | |
exit 1 | |
fi | |
EXPIRE_EXP="$(openssl x509 -noout -text -in $FILENAME | grep 'Not After' | sed -e 's/[^:]\+: //')" | |
EXPIRE=$(date --date "$EXPIRE_EXP") | |
THRESHOLD=$(date -d "$EXPIRE_EXP -30 days" +"%s") | |
TODAY=$(date +"%s") | |
if [ $THRESHOLD -lt $TODAY ]; then | |
echo "SSL CERT FILE (WILL) EXPIRE!!!!! EXPIRE: $EXPIRE" | |
echo "$FILENAME" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment