cURL / Mailing Lists / curl-library / Single Mail


libcurl with client ssl certificate

From: Chris Baylis <>
Date: Sun, 19 Aug 2012 07:52:00 +1000


I am trying to use libcurl in C to connect a site that uses client SSL
I can acheive this task with curl, but not libcurl.

Successful example with curl
$ curl -vv -E cert.pem https://someURL
* About to connect() to someURL port 443 (#0)
* Trying connected
* Connected to someURL ( port 443 (#0)
Enter PEM pass phrase:
* successfully set certificate verify locations:
* CAfile: none
  CApath: /etc/ssl/certs
Webpages dowloads succesfully and I can see some debuging output I added in
PHP verifying that the client certificate was used.

I have taken the simplessl.c example from the your site and changed only the
following lines so far.

const char *pPassphrase = "<PASSWORD SET HERE>";
static const char *pCertFile = "cert.pem";
static const char *pCACertFile="cert.pem";
pKeyName = "cert.pem";
pKeyType = "PEM";
pEngine = NULL;
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);

The result of this is as follows
$ gcc -lcurl simplessl.c
$ ./a.out
* About to connect() to https://someURL port 443 (#0)
* Trying * connected
* Connected to someURL ( port 443 (#0)
* found 142 certificates in /etc/ssl/certs/ca-certificates.crt
* error reading X.509 key or certificate file
* Closing connection #0
* SSL connect error
curl_easy_perform() failed: SSL connect error

I would greatly appreciate any help or advice you may be able to give.

List admin:
Received on 2012-08-18