Private key contains series of numbers. Two numbers are for the Public key, others are for Private key.
Public key bits are also embedded in the Certificate.
To check that Public key in your Certificate matches the "Public key" inside your Private key, you need to view the Certificate & Private key and compare the numbers.
To view the Certificate and Private key please follow the commands.
The 'modulus' and the 'public exponent' portions in the key and the Certificate must match. Human eye it is dificult to compare the 'public exponent', it is usually 65537. To compare these in shorter number follow the commands, it will show the hash.
Compare it in single command
(stdin)= 065ae4a31a6f5623e86f5bc17532c7e3
(stdin)= cce154b2e767186b3e146af70101f046
You can also compare CSR with the Private key with following command
Public key bits are also embedded in the Certificate.
To check that Public key in your Certificate matches the "Public key" inside your Private key, you need to view the Certificate & Private key and compare the numbers.
To view the Certificate and Private key please follow the commands.
# openssl x509 -noout -text -in domain.crt
# openssl rsa -noout -text -in domain.key
# openssl rsa -noout -text -in domain.key
The 'modulus' and the 'public exponent' portions in the key and the Certificate must match. Human eye it is dificult to compare the 'public exponent', it is usually 65537. To compare these in shorter number follow the commands, it will show the hash.
# openssl x509 -noout -modulus -in domain.crt | openssl md5
Result: (stdin)= 065ae4a31a6f5623e86f5bc17532c7e3
# openssl rsa -noout -modulus -in domain.key | openssl md5
Result: (stdin)= cce154b2e767186b3e146af70101f046Compare it in single command
# openssl x509 -noout -modulus -in domain.crt | openssl md5 ;\
openssl rsa -noout -modulus -in domain.key | openssl md5
Result: openssl rsa -noout -modulus -in domain.key | openssl md5
(stdin)= 065ae4a31a6f5623e86f5bc17532c7e3
(stdin)= cce154b2e767186b3e146af70101f046
You can also compare CSR with the Private key with following command
# openssl req -noout -modulus -in domain.csr | openssl md5
Result: (stdin)= cce154b2e767186b3e146af70101f046