cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl

From: nei <neiamaralf_at_yahoo.com.br>
Date: Fri, 26 Oct 2012 13:46:13 -0200

On 10/26/2012 11:53 AM, Daniel Stenberg wrote:
> On Fri, 26 Oct 2012, nei wrote:
>
>> Strangely, when i use curl to connect with server on command line,
>> the request is successfull
>
> Then add "--libcurl code.c" to the curl command line and see which
> options it uses and compare them with your code!
>
The error message remains the same, the command line that i'm using is:
./curl --libcur code.c -k --sslv3 -v --key pvkey.pem --pass dirsicaf
--cacert cacert.pem --cert pubcert.pem
https://homologacao.nfe2.fazenda.pr.gov.br/nfe/NFeRecepcao2?wsdl

The auto-generated c code is:

/********* Sample code generated by the curl command line tool **********
  * All curl_easy_setopt() options are documented at:
  * http://curl.haxx.se/libcurl/c/curl_easy_setopt.html
  ************************************************************************/
#include <curl/curl.h>

int main(int argc, char *argv[])
{
   CURLcode ret;
   CURL *hnd;

   hnd = curl_easy_init();
   curl_easy_setopt(hnd, CURLOPT_URL,
"https://homologacao.nfe2.fazenda.pr.gov.br/nfe/NFeRecepcao2?wsdl");
   curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1L);
   curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/7.28.0");
   curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
   curl_easy_setopt(hnd, CURLOPT_KEYPASSWD, "dirsicaf");
   curl_easy_setopt(hnd, CURLOPT_CAINFO, "cacert.pem");
   curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYHOST, 1L);
   curl_easy_setopt(hnd, CURLOPT_SSLVERSION, (long)CURL_SSLVERSION_SSLv3);
   curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
   curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);

   /* Here is a list of options the curl code used that cannot get generated
      as source easily. You may select to either not use them or implement
      them yourself.

   CURLOPT_WRITEDATA set to a objectpointer
   CURLOPT_WRITEFUNCTION set to a functionpointer
   CURLOPT_READDATA set to a objectpointer
   CURLOPT_READFUNCTION set to a functionpointer
   CURLOPT_SEEKDATA set to a objectpointer
   CURLOPT_SEEKFUNCTION set to a functionpointer
   CURLOPT_ERRORBUFFER set to a objectpointer
   CURLOPT_SSLCERT set to a objectpointer
   CURLOPT_SSLKEY set to a objectpointer
   CURLOPT_STDERR set to a objectpointer
   CURLOPT_DEBUGFUNCTION set to a functionpointer
   CURLOPT_DEBUGDATA set to a objectpointer
   CURLOPT_HEADERFUNCTION set to a functionpointer
   CURLOPT_HEADERDATA set to a objectpointer

   */

   ret = curl_easy_perform(hnd);

   curl_easy_cleanup(hnd);
   hnd = NULL;

   return (int)ret;
}
/**** End of sample code ****/

Note that CURLOPT_SSLKEY and CURLOPT_SSLCERT hane not been generated,
the modified code is:
curl_easy_setopt(curl, CURLOPT_URL,
"https://homologacao.nfe2.fazenda.pr.gov.br/nfe/NFeRecepcao2?wsdl");
   curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
   curl_easy_setopt(curl, CURLOPT_USERAGENT, "curl/7.28.0");
   curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L);
   curl_easy_setopt(curl, CURLOPT_KEYPASSWD,
"dirsicaf");curl_easy_setopt(curl,CURLOPT_SSLKEY,"pvkey.pem");curl_easy_setopt(curl,CURLOPT_SSLCERT,"pubcert.pem");
   curl_easy_setopt(curl, CURLOPT_CAINFO, "cacert.pem");
   curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 1L);
   curl_easy_setopt(curl, CURLOPT_SSLVERSION, (long)CURL_SSLVERSION_SSLv3);
   curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
   curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);

       res = curl_easy_perform(curl);
And error message is:
* About to connect() to homologacao.nfe2.fazenda.pr.gov.br port 443 (#0)
* Trying 200.189.113.223...
* connected
* Connected to homologacao.nfe2.fazenda.pr.gov.br (200.189.113.223) port
443 (#0)
* unable to use client certificate (no key found or wrong pass phrase?)
* Closing connection #0
* Problem with the local SSL certificate
curl_easy_perform() failed: Problem with the local SSL certificate

Thanks
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-10-26