I used the openssl to generate a self-signed certificate using following command
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365ls
I am sending this cert.pem with the curl command
curl --header 'Accept: application/json' --header 'Authorization: Bearer 043473b9-5cf4-3dcc-b7a6-32813f6e4df2' 'https://localhost:8243/pizzashack/1.0.0/menu' --cert cert.pem --key key.pem -k -v
But this fails with the error: error reading X.509 key or certificate file: Error in parsing when sending certificate in Curl Request
How can i overcome this issue?
Here's a solution to this. This occurs when curl is unable to decrypt my key.pem file which is encrypted by default. We can use the -nodes directive when generating the certificate to avoid encrypting the keys.
certificate generated from following request worked correctly.
openssl req -newkey rsa:2048 -x509 -keyout pii_key.pem -out piisp.pem -days 3650 -nodes