Skip to content

Instantly share code, notes, and snippets.

@agustik
Last active September 28, 2016 08:36
Show Gist options
  • Save agustik/deeee6ba97452b1534e99c3b437cd4f8 to your computer and use it in GitHub Desktop.
Save agustik/deeee6ba97452b1534e99c3b437cd4f8 to your computer and use it in GitHub Desktop.
Finds nginx certs and checks enddate
#!/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