Confirm that a certificate matches a private key with OpenSSL

To prep for a maintenance to thwart HeartBleed I wanted to confirm that a new certificate matched a new key that I received from my developers
You can do this easily with two openssl commands:


$ openssl x509 -noout -modulus -in server.crt | openssl md5
c73310ec894a2518a153144e7abb3c19

Now do the same for the private key

$ openssl rsa -noout -modulus -in server.key | openssl md5
c73310ec894a2518a153144e7abb3c19

If these two hashes match, then the certificate and key are a match