Skip to content

Instantly share code, notes, and snippets.

@ikurni
Last active May 14, 2020 06:00
Show Gist options
  • Save ikurni/0fdfa29621b7e25e55446f2003872329 to your computer and use it in GitHub Desktop.
Save ikurni/0fdfa29621b7e25e55446f2003872329 to your computer and use it in GitHub Desktop.
Verify SSL Cert
How do I verify that a private key matches a certificate?
To verify that a private key matches its certificate you need to compare the modulus of the certificate against the modulus of the private key.
Please follow the below command to view the modulus of the certificate.
# openssl x509 -noout -modulus -in server.crt | openssl md5
Now you will receive the modulus something like a77c7953ea5283056a0c9ad75b274b96
Please follow the below command to view the modulus of the private key.
# openssl rsa -noout -modulus -in myserver.key | openssl md5
Now you should get the modulus as same as certificate modulus above. i.e a77c7953ea5283056a0c9ad75b274b96
If the modulus of the certificate and the modulus of the private key do not match, then you’re not using the right private key. You can either create a brand new key and CSR and send contact support or do a search for all private keys on the system and compare their modulus.
Please follow the below command to search for all private keys on your server .
# find / -name *.key
openssl verify -verbose -CAfile file-ca.cer file-cert.cer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment