Recently one of my user asked me when he try to install a certificate on their website he is facing on issue his certificate does not match with private key and getting an error.
In this article I will describe how you can match private key with CSR.
There are two method :
1. Using OpenSSL and MD5
2. Using OpenSSL and sha256sum
Using OpenSSL and MD5
Using OpenSSL and MD5 method, The MD5 value of certificate key and csr should be same. If any of MD5 is different means that file doesn’t match.
# openssl rsa -noout -modulus -in example_domain.key | openssl md5 # openssl req -noout -modulus -in example_domain.csr | openssl md5 # openssl x509 -noout -modulus -in example_domain.crt | openssl md5
Now check the MD5 value for all the keys it should be same. If MD5 value is same means your prive key matches with csr.
For Example:
# openssl rsa -noout -modulus -in example_domain.key | openssl md5 (stdin) = 68falr3343fadfafw3434dfaedfa3434 # openssl req -noout -modulus -in example_domain.csr | openssl md5 (stdin) = 68falr3343fadfafw3434dfaedfa3434 # openssl x509 -noout -modulus -in example_domain.crt | openssl md5 (stdin) = 68falr3343fadfafw3434dfaedfa3434
Using OpenSSL and sha256sum
In this method check for the SHA sum valued of all files it should be same for all.
# openssl pkey -in example_domain.key -pubout -outform pem | sha256sum # openssl x509 -in example_domain.crt -pubkey -noout -outform pem | sha256sum # openssl req -in example_domain.csr -pubkey -noout -outform pem | sha256sum
Now check the sha2 sum value for all the keys it should be same. If sha2 sum value is same means your prive key matches with csr.
For Example:
# openssl pkey -in example_domain.key -pubout -outform pem | sha256sum f3bcrefaldfjadf23434adfjaldfja34343ae34143fafdafaf23424323 - # openssl x509 -in example_domain.crt -pubkey -noout -outform pem | sha256sum f3bcrefaldfjadf23434adfjaldfja34343ae34143fafdafaf23424323 - # openssl req -in example_domain.csr -pubkey -noout -outform pem | sha256sum f3bcrefaldfjadf23434adfjaldfja34343ae34143fafdafaf23424323 -
Thanks:)
If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.
Leave a Comment