How to verify whether a private key matches with the SSL certificate ?

This is a very common question that comes to our mind while setting up SSL in our applications. How to verify whether the key matches with the SSL certificate ?

A very easy way to verify that is given below.

We need to compare the modulus of the certificate against the modulus of the private key.

Execute the below command to get the modulus of a certificate.

openssl x509 -noout -modulus -in mycertificate.crt | openssl md5

This will generate the modulus something like e091f305089662689d62126d49910031 

Execute the below command to get the modulus of a private key.

openssl rsa -noout -modulus -in mykey.key | openssl md5

This will generate the modulus of the private key. You should get the key modulus as same as certificate modulus above. i.e e091f305089662689d62126d49910031

If both the modulus are same, we can say that the certificate and the key are matching.

Advertisements

About amalgjose
I am an Electrical Engineer by qualification, now I am working as a Software Engineer. I am very much interested in Electrical, Electronics, Mechanical and now in Software fields. I like exploring things in these fields. I like travelling, long drives and very much addicted to music.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: