How to fix AH02565: Certificate and private key do not match

cn flag

We have an application hosted on Ubuntu apache server and letsencrypt SSL is installed there. Now i want to change Letsencrypt ssl certificate by Digicert certificate. I followed the Digicert ssl installation document and when i try to start my apache server its gonna failed. After check error log i found below error.

AH02565: Certificate and private key from /etc/cert/domain_name.crt and /etc/cert/domain_name.key do not match
AH00016: Configuration Failed

Below is my "000-default-le-ssl.conf" page script

<VirtualHost *:443>
    SSLEngine On
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ### This is using in Letsencrypt SSL certificates
    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/
    SSLCertificateKeyFile /etc/letsencrypt/live/

    ### Change this for DigiCert SSL certification but getting error when enable below line
    #SSLCertificateFile /etc/cert/domain_name.crt
    #SSLCertificateKeyFile /etc/cert/domain_name.key
    #SSLCertificateChainFile /etc/cert/DigiCertCA.crt

Can anybody point me in the right direction for what i'm doing wrong?

Michael Hampton avatar
cz flag
You have enabled Let's Encrypt certificate, not Digicert certificate.
Paul avatar
cn flag
When comment the Let's Encrypt certificate and enable the Digicert certificate. I get above mention error.
ru flag

The private key must match with the certificate('s public key) you use. Otherwise you won't be able to use them together.

One way to make sure both key and certificate match (certificate comes from the private key being used) is by checking their modulus with openssl.

openssl rsa -in file.key -noout -modulus

openssl x509 -in file.crt -noout -modulus

Note: If certificate or key are not in ASCII you must add "-inform DER" to the specific file.

The output of both commands must be the same.


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.