Last active
August 29, 2015 14:00
-
-
Save gene1wood/11064617 to your computer and use it in GitHub Desktop.
Determine the modulus of a certificate, key or certificate request and output it for the purposes of comparing them to confirm they match
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 | |
if grep -- ' PRIVATE KEY-' "$1" >/dev/null; then | |
modulus="`openssl rsa -noout -modulus -in "$1" | md5sum | awk '{print $1}'`" | |
elif grep -- '-BEGIN CERTIFICATE REQUEST-' "$1" >/dev/null; then | |
modulus="`openssl req -noout -modulus -in "$1" | md5sum | awk '{print $1}'`" | |
elif grep -- '-BEGIN CERTIFICATE-' "$1" >/dev/null; then | |
modulus="`openssl x509 -noout -modulus -in "$1" | md5sum | awk '{print $1}'`" | |
else | |
modulus="unknown" | |
fi | |
#if [ "${1##*.}" = "key" ]; then | |
# modulus="`openssl rsa -noout -modulus -in $1 | md5sum | awk '{print $1}'`" | |
#elif [ "${1##*.}" = "crt" ]; then | |
# modulus="`openssl x509 -noout -modulus -in $1 | md5sum | awk '{print $1}'`" | |
#elif [ "${1##*.}" = "csr" ]; then | |
# modulus="`openssl req -noout -modulus -in $1 | md5sum | awk '{print $1}'`" | |
#else | |
# modulus="unknown" | |
#fi | |
echo "$modulus $1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment