Created
May 27, 2022 03:28
-
-
Save able8/104bf744138ef2e88461a0140a28667e to your computer and use it in GitHub Desktop.
check SSL certificate and PGP key expiration date with shell
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 | |
# check TLS/SSL certificate expiration date | |
# openssl x509 -text -noout -in inputfile | |
# https://www.sslshopper.com/certificate-decoder.html | |
echo -e "\n## SSL Certificates List: \n\n| File Name | Valid From | Valid To | Comment |\n| --- | --- | --- | --- |" >> README.md | |
for file in $(find .); do | |
if test -f $file; then | |
if grep -q "\-BEGIN CERTIFICATE\-" $file; then | |
echo "checking: $file" | |
result=$(openssl x509 -text -noout -in $file) | |
validateFrom=$(echo "$result" | grep "Not Before" | sed "s/Not Before: //g") | |
validateTo=$(echo "$result" | grep "Not After" | sed "s/Not After : //g") | |
echo "| $file | $validateFrom | $validateTo | |" >> README.md | |
fi | |
fi | |
done | |
# Check PGP key expiration date | |
# gpg --show-keys inputFile | |
echo -e "\n## PGP Keys List: \n\n| File Name | Valid From | Valid To | Comment |\n| --- | --- | --- | --- |" >> README.md | |
for file in $(find .); do | |
if test -f $file; then | |
if grep -q "BEGIN PGP PUBLIC KEY BLOCK" $file; then | |
echo "checking: $file" | |
result=$(gpg --show-keys $file) | |
validateFrom=$(echo "$result" | awk '/pub/{print $3}') | |
validateTo=$(echo "$result" | awk '/pub/{print $5 $6}') | |
echo "| $file | $validateFrom | $validateTo | |" >> README.md | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment