Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to set private key file: './cert.pem' type PEM

Tags:

curl

openssl

I am using curl to download data from a https site using public certificate files.

System information:

  • OS: fedora 14
  • curl: curl 7.30.0
  • openssl: OpenSSL 1.0.0a-fips

The command is,

curl -v "https://<ip:<port>" --cert "./cert.pem" --cacert "./cacert.pem" --cert-type PEM * About to connect() to kng.com port 443 (#0) *   Trying 11.19.37.123... * Adding handle: conn: 0x8189e68 * Adding handle: send: 0 * Adding handle: recv: 0 * Curl_addHandleToPipeline: length: 1 * - Conn 0 (0x8189e68) send_pipe: 1, recv_pipe: 0 * Connected to fkng.com (11.19.37.123) port 443 (#0) * unable to set private key file: './cert.pem' type PEM * Closing connection 0 curl: (58) unable to set private key file: './cert.pem' type PEM 

I have have given all the permission to the .pem file, still curl is throwing an error.

like image 946
user1495372 Avatar asked May 18 '13 13:05

user1495372


1 Answers

After reading cURL documentation on the options you used, it looks like the private key of certificate is not in the same file. If it is in different file, you need to mention it using --key file and supply passphrase.

So, please make sure that either cert.pem has private key (along with the certificate) or supply it using --key option.

Also, this documentation mentions that Note that this option assumes a "certificate" file that is the private key and the private certificate concatenated!

How they are concatenated? It is quite easy. Put them one after another in the same file.

You can get more help on this here.

I believe this might help you.

like image 132
doptimusprime Avatar answered Sep 22 '22 03:09

doptimusprime