Last active
June 8, 2018 19:37
-
-
Save besmirzanaj/9d25b104308df9a1d1cc64d6af2cd03d to your computer and use it in GitHub Desktop.
check if a certificate was generated by provided key
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
#!/bin/bash | |
# check certificate if it is generated from this key | |
# usage check_ssl_key_crt.sh "key file" "certificate" | |
[ $# -eq 0 ] && { echo "Usage: $0 'key file' ' ' 'cert file'" exit 999; } | |
if [[ $((openssl x509 -noout -modulus -in $2 | openssl md5 | awk '{print $2}'; openssl rsa -noout -modulus -in $1 | openssl md5 | awk '{print $2}') | uniq -c | wc -l) -eq 1 ]] | |
then printf "Everything ok with this certificate.\n It was generated by key $1\n" | |
else printf "Certificate $2 compromised or generated with another key." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment