Using client certificate in Curl command

sunsin1985 picture sunsin1985 · Jul 9, 2015 · Viewed 165.1k times · Source

Curl Command:

curl -k -vvvv \
  --request POST \
  --header "Content-Type: application/json" \
  --cert client.pem:password \
  --key key.pem \
  "https://test.com:8443/testing"

I am trying to send a client certificate using Curl command specified above. I am trying to know the following:

  1. What is the HTTP request header that I should be looking at the server side to pull out the client certificate from the HTTP Request.

  2. If I cannot pull out the client certificate on the server side from the HTTP Request, can I add a custom request header in the HTTP Request and send the client certificate as a value of that custom header. It would be great if someone could provide me an example of this approach.

Answer

reachlin picture reachlin · Aug 23, 2017

This is how I did it:

curl -v \
  --key ./admin-key.pem \
  --cert ./admin.pem \
  https://xxxx/api/v1/