-
-
Save dirkakrid/92a004776c2bc291cc762cfd28e5d90d 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