Page 1 of 1

Curl and SSL

Posted: 18 Nov 2014 10:46
by Tonton Luc
Hi,

The following VP 7.3 code generate an error 35 when the URL start by https://...

Code: Select all

  startCase(Action,URL) :-           Action = 1,             try                 ResultStream = outputStream_String::new(),                 Connection = vPcURL::new(ResultStream, caseCompletion, Action),                 _ = Connection:curl_easy_setopt(vPcURL::cURLOPT_HTTPGET, vPcURL::i(1)),                 _ = Connection:curl_easy_setopt(vPcURL::cURLOPT_URL, vPcURL::s(URL)),                 _ = Connection:curl_easy_perform()             catch _ do                 vpiCommonDialogs::note(string::format("startCase % pas ok.", Action)),                 succeed()             end try.
Any :idea: ...or maybe it's not possible to use Curl with HTTPS ?

Posted: 20 Nov 2014 21:38
by Jan de Lint
I Have never looked into vpcurl/https. Do you use the latest version of vpcurl?
Does the particular URL support https?

And when using the command line version of curl, does it then work?

Error 35 means CURLINFO_CONDITION_UNMET as you can find in VPcURLconst.i
Googling for it's meaning it is not very helpful I'm afraid...
]an

Posted: 21 Nov 2014 7:49
by Tonton Luc
Hi,


Thanks for your help. Using command line version, I need to add -k option with HTTPS.
But I don't know which constant I need to use to reproduce this option (in VPcURL.i) ?

Posted: 21 Nov 2014 9:25
by Jan de Lint
If you add the opton --libcurl on the commandline, curl is supposed to tell you what to use in libcurl.
Actually the docs in curl are very good for such a complicated matter. Bit still it remains hard to understand. Some more background info: http://curl.haxx.se/docs/sslcerts.html.
The equivalent option is
cURLOPT_SSL_VERIFYPEER which should be set to false.
Let us hear from you - give us some info on what you already tried..
]an

Posted: 21 Nov 2014 9:54
by Tonton Luc
I add "cURLOPT_SSL_VERIFYPEER = 00064." in VPcURL.i and add the following line in my code :

Code: Select all

_ = Connection:curl_easy_setopt(vPcURL::cURLOPT_SSL_VERIFYPEER, vPcURL::i(0)),
but I've always the same error 35.

I just need to recover programmatically the contain of html pages like : https://www.chevrolet.fr/la-gamme/aveo-5portes/

If I delete the "s" in "https", Curl works fine => maybee it is the solution : every time I recover programmatically a link started by "https", I delete the "s" before to continue...

Re:

Posted: 23 Nov 2014 21:09
by Jan de Lint
Tonton Luc wrote:I add "cURLOPT_SSL_VERIFYPEER = 00064." in VPcURL.i and add the following line in my code :

Code: Select all

_ = Connection:curl_easy_setopt(vPcURL::cURLOPT_SSL_VERIFYPEER, vPcURL::i(0)),
but I've always the same error 35.
Looks ok to me what you did. In the latest version of VPcURL all constants are predefined in VPcURLconst.i so I gather you are not using the latest version of VPcURL. Hence we are not talking the same thing.
If you leave out the s, curl falls back to non-SSL (non-TLS) mode. If that also works, it's fine with me. Many sites - where security is not a major issue - support both.
I will try and build a testcase for the url you mentioned.
]an

Posted: 24 Nov 2014 9:37
by Tonton Luc
Hi,

If the latest version of VPcURL works with VP 7.3, where do I found it ?

Re:

Posted: 24 Nov 2014 10:33
by Jan de Lint
Tonton Luc wrote:Hi,

If the latest version of VPcURL works with VP 7.3, where do I found it ?
I don't know if it works with 7.3 (too long ago :? ). I know it works with 7.4 and I know I had to make a change somewhere along the line. It had to do with the way foreign code (dll's) is called.
The package is here
VpCurl revised
I'm pretty convinced it works with the student version of 7.5 but that won't help you very much.
]an

Posted: 24 Nov 2014 20:33
by Jan de Lint
Tonton,
For the record, I can confirm that the following piece of code works like a charm:

Code: Select all

class predicates     tryTLS_next : vPcURL::connectionReturnHandlerP. clauses     tryTLS()  :-           C1 = vPcURL::new(tryTLS_next),         C1:curl_easy_setopt(cURLOPT_SSL_VERIFYPEER,i(0)),         C1:curl_easy_setopt(cURLOPT_URL, s("https://www.toernooiklapper.nl/tools/index.php")),         C1:curl_easy_perform().       tryTLS_next(_Returncode, Conn) :-         Content = Conn:getOutput(),         stdIO::write("\n",Content).
Success,
]an

Posted: 25 Nov 2014 10:14
by Tonton Luc
Hi,

Your code works fine too in my machine with VP 7.3 an the VPcURL revised.

But, when I test using my URL ("https://www.chevrolet.fr/la-gamme/aveo-5portes/") => I've the following error (with any number) :
SSL connect error
:?:

Posted: 25 Nov 2014 11:22
by Jan de Lint
I assume it has to do with the slash / at the end of the url.
Perhaps it works if you leave that out?

Correction: no good! This requires further digging into SSL.
https://www.google.fr works fine.