Last active
December 6, 2016 07:10
-
-
Save mikemackintosh/2a854c040d4b4bc0ae8a to your computer and use it in GitHub Desktop.
Validate x509 (SSL) Certs and Keys using Modulus
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
for i in `ls -1 *.key`; do | |
cert=`echo $i |sed -e 's/\.key//'`; | |
c=$((\ | |
openssl x509 -noout -modulus -in "${cert}.crt" 2>/dev/null| \ | |
openssl md5; \ | |
openssl rsa -noout -modulus -in "${cert}.key" 2>/dev/null| \ | |
openssl md5)\ | |
|uniq \ | |
|wc -l); | |
test $c -gt 1 && \ | |
(echo "Validation failed for: ${cert}" && exit 0) \ | |
|| \ | |
echo "Validation succeeded for: ${cert}"; | |
done |
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
Validation failed for: BLAH.com | |
Validation succeeded for: buttsec.org |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment