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 req -noout -modulus -in  server.csr | openssl md5
(stdin)= 395cb6f3a0def959d81f8f6a26d12749

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

openssl x509 -noout -modulus -in ssl-bundle.crt | 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.