Thursday, August 10, 2017

Curl Command example with client Key to https Server

To communicate with https Server by curl command, if a client private key is required, it is not simple like as i thought. my_client.12 is my client key and I need to convert to the other format. Before starting, check your key.
openssl pkcs12 -info -in my_client.12



Check the Server sertificate
openssl s_client -showcerts -connect www.domain.com:443


If you see that all right. you will be able to communicate with the https server which requires client key.

Convert the client key
openssl pkcs12 -in my_client.12 -out client.pem -clcerts -nokeys
openssl pkcs12 -in my_client.12 -out key.pem -nocerts
openssl rsa -in key.pem -out newkey.pem


And now finally, you can communicate with the server.
curl -v -G  -k --key newkey.pem --cert ./client.pem:password https://www.domain.com/path

No comments:

Post a Comment