openssl: No certificate matches private key / chained certificate

user643605 picture user643605 · Jul 30, 2011 · Viewed 9.5k times · Source

I am getting this error while binding a chained certificate with a private key:

"No certificate matches private key"

the command I use is the following:

openssl pkcs12 -export -in chainedcertificate.pem -inkey private.pem -name MyCert -out chained.p12

Inside my chainedcertificate.pem is three blocks of BEGIN/END CERTIFICATE. CA, Intermediate and user certificate are in the file in reverse order (i.e. CA being last).

When I remove the the two last blocks and leave only the user certifcate, the chained.p12 is generated without any error.

Why would the insertion of the root certificate and intermediate would compromise the creation with this kind of error message ???

Answer

Dilettant picture Dilettant · Jul 30, 2011

I think you need to provide the user cert first drilling deeper until the CA is reached at the end of the file. At least I would try this. Maybe I misread your description of the actual order you selected.