Skip to content

Instantly share code, notes, and snippets.

@SaveTheRbtz
Created January 13, 2015 07:14
Show Gist options
  • Save SaveTheRbtz/613e66feccec4468f80a to your computer and use it in GitHub Desktop.
Save SaveTheRbtz/613e66feccec4468f80a to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Simple utility to check that all *.crt files match corresponding *.key's
#
for FILE in *.crt; do
CERT="$FILE"
KEY="${FILE%crt}key"
if [ ! -f "$KEY" ]; then
continue
fi
MODULUS_CERT="$(openssl x509 -noout -modulus -in $CERT)"
MODULUS_KEY="$(openssl rsa -noout -modulus -in $KEY)"
if [ "$MODULUS_CERT" != "$MODULUS_KEY" ]; then
echo "MISMATCH: $CERT <-> $KEY"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment