Check if an SSL certificate and private key match in two simple commands. The OpenSSL commands below will require you to replace <file> with your file’s name.
For your SSL certificate:1
openssl x509 -noout -modulus -in <file> | md5sum
For your RSA private key:
openssl rsa -noout -modulus -in <file> | md5sum
The output of these commands should be identical. If it isn’t, your keys do not match.
- The pipe to md5sum is solely to make the output shorter and easier to visually compare ↩
Hey, this is a good one to keep handy. Just wanted to mention to your readers that -modulus for both ‘x509′ and ‘rsa’ applications in openssl prints the RSA key modulus and even those values can be compared to confirm a match. The pipe to md5sum/sha1sum simply help make things easier when visually comparing.
Good one!