curl with https

663 views
Skip to first unread message

Paola Bruccoleri

unread,
May 2, 2016, 6:07:53 PM5/2/16
to Lista Harbour-users

Hello

I need to consume a web service query, using CURL. The webservice is https.

endpointUrl:= "https://115efactura.info/ws/ws_efacturainfo_consultas.php"

I have the certificate with this tutorial:  (the file thawtePrimaryRootCA.crt)
http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/
with the qick fix, works ok but with the proper fix, NO.
can you help me to do well?
very thanks!


cc1 := ""
cSoapAction:= 'SOAPAction: "'+endpointURL+'/'+cMetodo+'"'
aHeader := {}
AADD(aHeader,"Content-Type: text/xml;charset=UTF-8" )
AADD(aHeader, cSoapAction )
curlHandle := curl_easy_init()

if !empty(curlHandle)
   /* Specify the Header  data */
   curl_easy_setopt(curlHandle, HB_CURLOPT_HTTPHEADER,aHeader)

   /* para usar https, 1era forma*/
   //curl_easy_setopt(curlHandle, HB_CURLOPT_SSL_VERIFYPEER, .f.)   ----> WORKS

   /* para usar https, 2da forma, obteniendo el certificado*/  ---> NO WORKS
   curl_easy_setopt(curlHandle, HB_CURLOPT_SSL_VERIFYPEER, .t.)
   curl_easy_setopt(curlHandle, HB_CURLOPT_SSL_VERIFYHOST, 0)
   curl_easy_setopt(curlHandle, HB_CURLOPT_CAINFO, GetCurrentFolder()+'\thawtePrimaryRootCA.crt') 

   /* Set the endpoint to send the POST to */
   curl_easy_setopt(curlHandle, HB_CURLOPT_URL, endpointUrl)

   /* Setup response data */
   curl_easy_setopt( curlHandle, HB_CURLOPT_DOWNLOAD )
   curl_easy_setopt( curlHandle, HB_CURLOPT_DL_BUFF_SETUP )

   /* Specify the POST data */
   curl_easy_setopt(curlHandle, HB_CURLOPT_POST, 1)
   curl_easy_setopt(curlHandle, HB_CURLOPT_POSTFIELDS, cxml)

   /* Do everything */
   curlErr := curl_easy_perform(curlHandle)
 ...................... ETC


Marek Horodyski

unread,
May 2, 2016, 8:45:49 PM5/2/16
to harbou...@googlegroups.com

Od: "Paola Bruccoleri" <pbruc...@adinet.com.uy>

Do: "Lista Harbour-users" <harbou...@googlegroups.com>;
Wysłane: 0:07 Wtorek 2016-05-03
Temat: [harbour-users] curl with https

Have you CURL with SSL or not?
Pleas read README.md and from <http://curl.haxx.se/>

Hello

I need to consume a web service query, using CURL. The webservice is https.

endpointUrl:= "https://115efactura.info/ws/ws_efacturainfo_consultas.php"

I have the certificate with this tutorial:  (the file thawtePrimaryRootCA.crt)
http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/
with the qick fix, works ok but with the proper fix, NO.
can you help me to do well?
very thanks!
*----------------------------------

Have you CURL with SSL or not?
Please read README.md and from <http://curl.haxx.se/> download CURL with SSL for your operating system.


Regards,
Marek Horodyski

Paola Bruccoleri

unread,
May 2, 2016, 9:24:51 PM5/2/16
to harbou...@googlegroups.com
El 02/05/2016 a las 21:45, Marek Horodyski escribió:

Od: "Paola Bruccoleri" <pbruc...@adinet.com.uy>

Do: "Lista Harbour-users" <harbou...@googlegroups.com>;
Wysłane: 0:07 Wtorek 2016-05-03
Temat: [harbour-users] curl with https

Have you CURL with SSL or not?
Pleas read README.md and from <http://curl.haxx.se/>

Hello Marek
I don't know :)
I installed curl and openssl and compile harbour with this.


Marek Horodyski

unread,
May 2, 2016, 9:29:00 PM5/2/16
to harbou...@googlegroups.com
*-----------------

It does not work like that. Go to https://curl.haxx.se/download.html


Regards,
Marek Horodyski


petr707

unread,
May 3, 2016, 3:26:22 AM5/3/16
to Harbour Users
Hi

This was usefull for me

= = = =
#define CERT_FILE  ("client.pem")
#define KEY_FILE   ("key.pem")
#define CINF_FILE  ("ca.pem")
....
lVerbose:=.t.
? curl_easy_setopt(curlHandle, HB_CURLOPT_VERBOSE, lVerbose )
.....
// Specify certificate
curl_easy_setopt(curlHandle, HB_CURLOPT_SSL_VERIFYPEER  , 1 )
//curl_easy_setopt(curlHandle, HB_CURLOPT_SSL_VERIFYHOST  , 2 )
curl_easy_setopt(curlHandle, HB_CURLOPT_CAINFO        ,dirx+"\"+CINF_FILE)
curl_easy_setopt(curlHandle, HB_CURLOPT_SSLCERT       ,dirx+"\"+CERT_FILE)
curl_easy_setopt(curlHandle, HB_CURLOPT_SSLKEY       , dirx+"\"+KEY_FILE)
curl_easy_setopt(curlHandle, HB_CURLOPT_SSLKEYPASSWD ,passphrase)

....
run  
test.exe  2>logssl.txt

===logssl.txt== some text was replaced===
*   Trying XXX...
* Connected to XXXX port .. (#0)
* successfully set certificate verify locations:
*   CAfile: ....ca.pem
  CApath: none
* SSL connection using TLSv1.0 / AES256-SHA
* Server certificate:
*   subject: ....
*   start date: 2013-02-19 07:24:07 GMT
*   expire date: 2023-02-20 07:24:07 GMT
*   common name: NNNNNNN (matched)
*   issuer: .................
*   SSL certificate verify ok.
> POST ........ HTTP/1.1
Host: XXXXXXXXXX:...
Accept: */*
Content-Type: text/xml; Charset=utf-8
SOAPAction: .......
Content-Length: 287

* upload completely sent off: 287 out of 287 bytes
< HTTP/1.1 200 OK
...

= = = =

вторник, 3 мая 2016 г., 1:07:53 UTC+3 пользователь Paola Bruccoleri написал:

Paola Bruccoleri

unread,
May 3, 2016, 10:12:23 AM5/3/16
to harbou...@googlegroups.com
El 02/05/2016 a las 22:28, Marek Horodyski escribió:


Have you CURL with SSL or not?
Pleas read README.md and from <http://curl.haxx.se/>

Hello Marek
I don't know :)
I installed curl and openssl and compile harbour with this.

*-----------------

It does not work like that. Go to https://curl.haxx.se/download.html


Hi Marek
in my curl installation, the build.txt has:

This is a development package of the cURL libcurl library:
http://curl.haxx.se/
Please direct any questions you may have regarding usage,
develoment, or bugs to one of the cURL mailing lists:
http://curl.haxx.se/mail/

All libs of this package are build with MinGW32 compiler;
this SDK can be used f.e. for static and dynamic linking.

version  : 7.34.0 RTMP SSH2 SSL SSPI LIBZ IDN SPNEGO
license  : http://curl.haxx.se/docs/copyright.html
built by : G. Knauf <in...@gknw.de>

curl 7.34.0 (i386-pc-win32) libcurl/7.34.0 OpenSSL/1.0.0k zlib/1.2.8 libidn/1.18 libssh2/1.4.3 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtmp rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN Largefile NTLM SPNEGO SSL SSPI libz
--------

yes, the package build with SSL....


Marek Horodyski

unread,
May 3, 2016, 10:30:10 AM5/3/16
to harbou...@googlegroups.com, Paola Bruccoleri



Od: "Paola Bruccoleri" <pbruc...@adinet.com.uy>
Do: harbou...@googlegroups.com;
Wysłane: 16:12 Wtorek 2016-05-03
Temat: Re: [harbour-users] curl with https

Hi,

can you write, to test, all example from first mail. Just in case with problems we will ask Victor of help. Viktor wrote that curl from his fork (harbour 3.4) is worked on https. On linux ssl is element of OS, on Windows we must they think about.


Regards,
Marek Horodyski


Reply all
Reply to author
Forward
0 new messages