curl-library
Re: Passing memory blocks instead of file names to curl_easy_setopt
Date: Tue, 3 Aug 2010 00:48:16 +0200
On Tuesday 03 August 2010 00:30:47 Mayur Srinivasan wrote:
> Is there a way to setup libcurl to use the root certificate, the client
> certificate and the client key from memory buffers rather than files?
> For example:
> Instead of using file names, I'd like to pass in memory blocks:
> curl_easy_setopt(m_curl_handle, CURLOPT_SSLCERT, m_pClientCert);
What does actually contain m_pClientCert? Is it text or binary data? If it
is text, it will be trated as file name (or nickname in case of NSS). If it
is binary data, it may crash badly.
> curl_easy_setopt(m_curl_handle, CURLOPT_SSLKEY, m_pClientKey);
> curl_easy_setopt(m_curl_handle, CURLOPT_CAINFO, m_pClientRootCert);
>
> I tried this, I get the error: unable to use client certificate (no key
> found or wrong pass phrase?)
> The same APIs work if I use file names.
The documentation sounds clear to me:
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTSSLCERT
I don't think there is a way to do waht you need through libcurl's API
enough generically. You can of course try to use the underlying SSL library
directly for that purposes, but your code will depend on the particular
library and break as soon as libcurl is built on top of different SSL
library. If you want to play with that, try the following option:
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTSSLCTXFUNCTION
Kamil
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-08-03