Skip to content

How to Check If Certificate, Private Key and CSR Match

Match Certificate with CSR. Certificate Key Matcher. How to Check If Certificate, Private Key, and CSR Matches. How to Match Private and SSL

Category
Security
Covers
SSL/TLS
On this page

This tutorial is helpful to verify that you are using correct Private key, or Certificate. You may face an issue when your certificate does not match to the private key and throws an error.

Method 1: Using OpenSSL and MD5

In the first method, The md5 value of certificate, key, and CSR should be same for all to work properly. If any of md5 is different means that file doesn’t relate to others.

$ openssl rsa -noout -modulus -in example.key | openssl md5
$ openssl req -noout -modulus -in example.csr | openssl md5
$ openssl x509 -noout -modulus -in example.crt | openssl md5

For example, check the md5 values are same for all the keys. It means they are related to each other and work properly.

Method 2: Using Openssl and sha256sum

Second method check for the SHA sum values of all files and check if the value of all files are same.

$ openssl pkey -in example.key -pubout -outform pem | sha256sum
$ openssl x509 -in example.crt -pubkey -noout -outform pem | sha256sum
$ openssl req -in example.csr -pubkey -noout -outform pem | sha256sum 

For example, check the sha2 sum values are same for all the keys. It means they are related to each other and work properly.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top