Skip to content

Instantly share code, notes, and snippets.

@dirkakrid
Forked from mikemackintosh/check.sh
Created December 6, 2016 07:10
Show Gist options
  • Save dirkakrid/92a004776c2bc291cc762cfd28e5d90d to your computer and use it in GitHub Desktop.
Save dirkakrid/92a004776c2bc291cc762cfd28e5d90d to your computer and use it in GitHub Desktop.
Validate x509 (SSL) Certs and Keys using Modulus
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
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