Last active
September 28, 2016 08:36
-
-
Save agustik/deeee6ba97452b1534e99c3b437cd4f8 to your computer and use it in GitHub Desktop.
Finds nginx certs and checks enddate
This file contains hidden or 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 | |
base=$1; | |
if [ -z "$base" ]; then | |
echo "Need input dir" | |
exit | |
fi | |
function certinfo { | |
info=$(openssl x509 -enddate -noout -in $1); | |
echo "$1: $info" | |
} | |
for file in $(ls $base); do | |
filepath=$base$file; | |
cert=$(grep "ssl_certificate " $base$file | grep -v '#' ); | |
ok=$(echo "$cert" | grep 'ssl_certificate' -q ); | |
if [[ $? -eq 0 ]]; then | |
certpath=$(echo "$cert" | awk '{print $2}' ); | |
certpath=$(echo "$certpath" | rev | cut -c 2- | rev); | |
certinfo $certpath; | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment