cURL / Mailing Lists / curl-library / Single Mail

curl-library

libcurl

From: nei <neiamaralf_at_yahoo.com.br>
Date: Fri, 26 Oct 2012 11:04:41 -0200

Hi, i'm trying connect to a https webservice with cURL, the code follows:

curl_global_init(CURL_GLOBAL_DEFAULT);

   curl = curl_easy_init();
   if(curl) {
     curl_easy_setopt(curl, CURLOPT_URL,
"https://homologacao.nfe2.fazenda.pr.gov.br/nfe/NFeRecepcao2?wsdl");
     curl_easy_setopt(curl, CURLOPT_WRITEHEADER, headerfile);
     while(1){
       curl_easy_setopt(curl,CURLOPT_VERBOSE,1L);

                     // if(pPassphrase)
     // curl_easy_setopt(curl,CURLOPT_SSLCERTPASSWD,pPassphrase);
                         curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS,
CURL_SSLVERSION_SSLv3);
                         curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER,
false);
curl_easy_setopt(curl,CURLOPT_SSLKEY,"pvkey.pem");

curl_easy_setopt(curl,CURLOPT_KEYPASSWD,"dirsicaf");
       curl_easy_setopt(curl,CURLOPT_SSLCERT,"pubcert.pem");
                         curl_easy_setopt(curl, CURLOPT_CAPATH, "./");
       curl_easy_setopt(curl,CURLOPT_CAINFO,"cacert.pem");
       //curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,1L);

       res = curl_easy_perform(curl);
       if(res != CURLE_OK)
         fprintf(stderr, "curl_easy_perform() failed: %s\n",
                 curl_easy_strerror(res));

       break; /* we are done... */
     }
     /* always cleanup */
     curl_easy_cleanup(curl);
   }

And i get this error message:
* 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

Strangely, when i use curl to connect with server on command line, the
request is successfull, this is the result:

* 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)
* successfully set certificate verify locations:
* CAfile: cacert.pem
   CApath: none
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Request CERT (13):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS handshake, CERT verify (15):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using EDH-RSA-DES-CBC3-SHA
* Server certificate:
* subject: C=BR; O=ICP-Brasil; OU=Secretaria da Receita Federal do
Brasil - RFB; OU=RFB e-CNPJ/EA; OU=ARSERPRO;
CN=homologacao.nfe2.fazenda.pr.gov.br
* start date: 201
* expire date: 201
* common name: homologacao.nfe2.fazenda.pr.gov.br (matched)
* issuer: C=B
* SSL certificate verify result: self signed certificate in
certificate chain (19), continuing anyway.
> GET /nfe/NFeRecepcao2?wsdl HTTP/1.1
> User-Agent: curl/7.28.0
> Host: homologacao.nfe2.fazenda.pr.gov.br
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
< Content-Type: text/xml
< Transfer-Encoding: chunked
< Date: Fri, 26 Oct 2012 13:03:37 GMT
<
<wsdl:definitions
targetNamespace='http://www.portalfiscal.inf.br/nfe/wsdl/NfeRecepcao2'
xmlns:http='http://schemas.xmlsoap.org/wsdl/http/'
xmlns:mime='http://schemas.xmlsoap.org/wsdl/mime/'
xmlns:s='http://www.w3.org/2001/XMLSchema'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:soap12='http://schemas.xmlsoap.org/wsdl/soap12/'
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:tm='http://microsoft.com/wsdl/mime/textMatching/'
xmlns:tns='http://www.portalfiscal.inf.br/nfe/wsdl/NfeRecepcao2'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'>
  <wsdl:documentation
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'>Servico destinado a
recepcao de mensagens de lote de NF-e.</wsdl:documentation>
  <wsdl:types>
   <s:schema elementFormDefault='qualified'
targetNamespace='http://www.portalfiscal.inf.br/nfe/wsdl/NfeRecepcao2'>
    <s:element name='nfeDadosMsg'>
     <s:complexType mixed='true'>
      <s:sequence>
       <s:any/>
      </s:sequence>
     </s:complexType>
    </s:element>
    <s:element name='nfeRecepcaoLote2Result'>
     <s:complexType mixed='true'>
      <s:sequence>
       <s:any/>
      </s:sequence>
     </s:complexType>
    </s:element>
    <s:element name='nfeCabecMsg' type='tns:nfeCabecMsg'/>
    <s:complexType name='nfeCabecMsg'>
     <s:sequence>
      <s:element maxOccurs='1' minOccurs='0' name='cUF' type='s:string'/>
      <s:element maxOccurs='1' minOccurs='0' name='versaoDados'
type='s:string'/>
     </s:sequence>
     <s:anyAttribute/>
    </s:complexType>
   </s:schema>
  </wsdl:types>
  <wsdl:message name='nfeRecepcaoLote2Soap12Out'>
   <wsdl:part element='tns:nfeRecepcaoLote2Result'
name='nfeRecepcaoLote2Result'></wsdl:part>
  </wsdl:message>
  <wsdl:message name='nfeRecepcaoLote2nfeCabecMsg'>
   <wsdl:part element='tns:nfeCabecMsg' name='nfeCabecMsg'></wsdl:part>
  </wsdl:message>
  <wsdl:message name='nfeRecepcaoLote2Soap12In'>
   <wsdl:part element='tns:nfeDadosMsg' name='nfeDadosMsg'></wsdl:part>
  </wsdl:message>
  <wsdl:portType name='NfeRecepcao2Soap12'>
   <wsdl:operation name='nfeRecepcaoLote2'>
    <wsdl:documentation
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'>Transmissao de Lote de
NF-e</wsdl:documentation>
    <wsdl:input message='tns:nfeRecepcaoLote2Soap12In'></wsdl:input>
    <wsdl:output message='tns:nfeRecepcaoLote2Soap12Out'></wsdl:output>
   </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name='NfeRecepcao2Soap12' type='tns:NfeRecepcao2Soap12'>
   <soap12:binding transport='http://schemas.xmlsoap.org/soap/http'/>
   <wsdl:operation name='nfeRecepcaoLote2'>
    <soap12:operation
soapAction='http://www.portalfiscal.inf.br/nfe/wsdl/NfeRecepcao2/nfeRecepcaoLote2'
style='document'/>
    <wsdl:input>
     <soap12:body use='literal'/>
     <soap12:header message='tns:nfeRecepcaoLote2nfeCabecMsg'
part='nfeCabecMsg' use='literal'></soap12:header>
    </wsdl:input>
    <wsdl:output>
     <soap12:body use='literal'/>
     <soap12:header message='tns:nfeRecepcaoLote2nfeCabecMsg'
part='nfeCabecMsg' use='literal'></soap12:header>
    </wsdl:output>
   </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name='NfeRecepcao2'>
   <wsdl:documentation
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'>Servico destinado a
recepcao de mensagens de lote de NF-e.</wsdl:documentation>
   <wsdl:port binding='tns:NfeRecepcao2Soap12'
name='NfeRecepcaoServicePort'>
    <soap12:address
location='https://ssefa00009.fazenda.pr.gov.br:8543/nfe/NFeRecepcao2'/>
   </wsdl:port>
  </wsdl:service>
* Connection #0 to host homologacao.nfe2.fazenda.pr.gov.br left intact
</wsdl:definitions>* Closing connection #0
* SSLv3, TLS alert, Client hello (1):

Can someone help me?

Thanks

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