CURL with client certificate and private key (mutual TLS)

Jay
Aug 9, 2021

--

Hi, Generally we can hit API endpoints like below

# curl -v https://my-api-endpoint.com

But it won’t work when client authentication is enabled on the server-side. In those cases, we have to include the private key and certificate in our request like below.

# curl -v - key ./private.key - cert ./cert.crt https://my-api-endpoint.com

Note: If you are in a different directory then use absolute paths like — key /home/ec2-user/private.key.

Bonus:

If you are behind the proxy then, provide proxy details with -x option.

# curl -v - key ./private.key - cert ./cert.crt https://my-api-endpoint.com -x proxy-url-or-ip.com:port

--

--

Responses (1)