GlobalSign Security Solutions Secure SSL Certificates  |  Home  |  Contact Us    
Search Technical Support & FAQs  
 
Certificates SSL menu divider Enterprise Solutions SSL menu divider Partners SSL menu divider Customer Support SSL menu divider About GlobalSign

 

 

How do I verify that a private key matches its Certificate in Apache?

A private key contains a series of numbers. Two of these numbers form the "public key", the others are part of the "private key". The "public key" bits are included when you generate a CSR, and subsequently form part of the associated Certificate.

To check that the public key in your Certificate matches the public portion of your private key, you simply need to compare these numbers. To view the Certificate and the key run the commands:

$ openssl x509 -noout -text -in server.crt
$ openssl rsa -noout -text -in server.key

The `modulus' and the `public exponent' portions in the key and the Certificate must match. As the public exponent is usually 65537 and it's difficult to visually check that the long modulus numbers are the same, you can use the following approach:

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

This leaves you with two rather shorter numbers to compare. It is, in theory, possible that these numbers may be the same, without the modulus numbers being the same, but the chances of this are overwhelmingly remote.

Should you wish to check to which key or certificate a particular CSR belongs you can perform the same calculation on the CSR as follows:

$ openssl req -noout -modulus -in server.csr | openssl md5


                 Provide Feedback
   
  SSL Certificate Supported Browsers
GlobalSign Inc (a member of GMO Internet Inc group TSE:9449) offers online security services and has been operating as a
trusted Root Certification Authority
for over 10 years. GlobalSign Certificates are trusted by all popular Browsers,
Operating Systems, Devices and Applications and include SSL, SSL Certificates, Extended SSL Certificates, Code Signing,
Personal Digital IDs
, Enterprise Digital IDs, internal PKI & Microsoft CA root signing.