Last active
February 10, 2020 09:09
-
-
Save rajeswari199/136f8c6d56e08deb0fee82c5e16523bf to your computer and use it in GitHub Desktop.
Outputs the private key validity for the provided SSL certificate.
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 | |
case $1 in | |
-[h?] | --help) | |
cat <<-____HALP | |
Usage: ${0##*/} [ --help ] | |
Execute it with the command: ./${0##*/} your_certificate.crt your_private_key.crt | |
____HALP | |
exit 0;; | |
esac | |
result=$((openssl x509 -noout -modulus -in $1 | openssl md5 ;\ | |
openssl rsa -noout -modulus -in $2 | openssl md5) | uniq) | |
echo "$result" | |
count=$(awk 'BEGIN{print gsub(ARGV[2],"",ARGV[1])}' "$result" "stdin") | |
if [ $count -eq 1 ]; then | |
echo -e "\e[1m\e[32mPRIVATE KEY MATCHES THE SSL CERTIFICATE" | |
else | |
echo -e "\e[1m\e[31mPRIVATE KEY AND SSL CERTIFICATE DOESNOT MATCH" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment