curl-library
RE: using CURL with SSL
Date: Wed, 9 Jan 2002 12:56:56 -0800
Minimum:
curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle,CURLOPT_URL,"https://.....");
curl_easy_setopt(curl_handle,CURLOPT_WRITEFUNCTION,WriteMemoryCallback);
curl_easy_setopt(curl_handle,CURLOPT_FILE,data);
curl_easy_setopt(curl_handle,CURLOPT_ERRORBUFFER,error);
if(curl_easy_perform(curl_handle)) {
// Error text is stored in the buffer set by CURLOPT_ERRORBUFFER
...
} else {
// data is in data buffer
...
}
curl_easy_cleanup(curl_handle);
Comprehensive:
curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle,CURLOPT_URL,"https://.....");
if(!isStrEmpty(params.payload)) {
curl_easy_setopt(curl_handle,CURLOPT_POST,1);
curl_easy_setopt(curl_handle,CURLOPT_POSTFIELDS,params.payload);
}
if(headerlist) {
curl_easy_setopt(curl_handle,CURLOPT_HTTPHEADER,headerlist);
}
if(!isStrEmpty(params.timeout)) {
long v = atol(params.timeout);
if(v <= 0) v = 60;
curl_easy_setopt(curl_handle,CURLOPT_TIMEOUT,v);
} else {
curl_easy_setopt(curl_handle,CURLOPT_TIMEOUT,60);
}
curl_easy_setopt(curl_handle,CURLOPT_WRITEFUNCTION,WriteMemoryCallback);
curl_easy_setopt(curl_handle,CURLOPT_FILE,data);
curl_easy_setopt(curl_handle,CURLOPT_ERRORBUFFER,error);
if(!isStrEmpty(params.proxy)) {
curl_easy_setopt(curl_handle,CURLOPT_PROXY,params.proxy);
if(isOptionSet(¶ms,"T")) {
curl_easy_setopt(curl_handle,CURLOPT_HTTPPROXYTUNNEL,1);
}
}
if(!isStrEmpty(params.clientcert)) {
curl_easy_setopt(curl_handle,CURLOPT_SSLCERT,params.clientcert);
}
if(!isStrEmpty(params.clientkeypass)) {
curl_easy_setopt(curl_handle,CURLOPT_SSLCERTPASSWD,params.clientkeypass);
}
if(!isStrEmpty(params.cacert)) {
curl_easy_setopt(curl_handle,CURLOPT_CAINFO,params.cacert);
curl_easy_setopt(curl_handle,CURLOPT_SSL_VERIFYPEER,1);
curl_easy_setopt(curl_handle,CURLOPT_SSL_VERIFYHOST,2);
}
if(isOptionSet(¶ms,"H")) {
curl_easy_setopt(curl_handle,CURLOPT_HEADER,1);
}
if(isOptionSet(¶ms,"N")) {
curl_easy_setopt(curl_handle,CURLOPT_SSL_VERIFYHOST,1);
}
if(!isStrEmpty(params.sslVer)) {
long v = atol(params.sslVer);
if(v != 3) v = 2;
curl_easy_setopt(curl_handle,CURLOPT_SSLVERSION,v);
}
if(curl_easy_perform(curl_handle)) {
// Error text is stored in the buffer set by CURLOPT_ERRORBUFFER
...
} else {
// data is in data buffer
...
}
curl_easy_cleanup(curl_handle);
curl_slist_free_all(headerlist);
> -----Original Message-----
> From: curl-library-admin_at_lists.sourceforge.net
> [mailto:curl-library-admin_at_lists.sourceforge.net]On Behalf Of Nataly
> Geimakher
> Sent: Wednesday, January 09, 2002 12:03 PM
> To: 'curl-library_at_lists.sourceforge.net'
> Subject: using CURL with SSL
>
>
> Hi,
>
> I need to send https requests to the server using CURL,
> Can you please send/direct me to any example that doing this?
> What set of CURL_OPT should I use? There are some for SSL but I not sure
> which one are essential..
> I am working on NT, but need to support Unix version too.
>
> Thank you.
> Nataly.
>
Received on 2002-01-09