I want to hit the REST endpoints of a Server, say xyz.com. They have provided certificates in PEM format which I should be including in my application while connecting to their endpoints.
My application is written on Spring Framework and I need to convert PEM to P12 format as Spring won't accept PEM. This is how I convert:
openssl pkcs12 -export -out certificate.p12 -inkey private.pem -in server_cert.pem
Where,
certificate.p12 = resultant p12 file
private.pem = private key
server_cert.pem = certificate files of the server
The error I get is:
No certificate matches private key.
Now my questions:
- Whose private key should be used to generate the P12 file from the PEM file?
- If the private key of client is used to generate p12, how could it possibly match with the certificate (error message becomes obvious)?
- Why would I need my private key to communicate with the server? As per my understanding, during an SSL session, the private key of the client doesn't come into the picture. Or is my understanding wrong?
- If the private key of the server is used to generate p12, why would they share it?
I'm a novice and therefore any links/suggested-reading/sources/answers are welcome.