Using openssl to match private key, cerificate and CSR

In a recent migration we came across a complete messed up server where SSL related keys, certificates and CSR are scattered all over.

We ran following openssl commands to match these three:

openssl <strong>req</strong> -noout -modulus -in  <strong>server.csr</strong> | openssl md5
(stdin)= 395cb6f3a0def959d81f8f6a26d12749

openssl <strong>rsa</strong> -noout -modulus -in <strong>myserver.key</strong> | openssl md5
(stdin)= 395cb6f3a0def959d81f8f6a26d12749

openssl <strong>x509</strong> -noout -modulus -in <strong>ssl-bundle.crt</strong> | openssl md5
(stdin)= 395cb6f3a0def959d81f8f6a26d12749

As you can see matching md5 indicated above triplet is a valid combo!

Make sure you use correct csr, key and crt file with respective openssl arguments.

Related: You may like this page about openssl commands.