Hi everyone,
I'm trying to retrieve some data from a url using curl. I'm using
the following code here:
void main()
{
ubyte[] data;
CURL* curl = curl_easy_init();
curl_easy_setopt(curl, CurlOption.url, "<Private HTTPS
Url>".toStringz);
curl_easy_setopt(curl, CurlOption.writefunction,
&callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &data);
curl_easy_setopt(curl, CurlOption.ssl_verifyhost, false);
curl_easy_setopt(curl, CurlOption.ssl_verifypeer, false);
curl_easy_setopt(curl, CurlOption.verbose, 1);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
But it's not working. I'm always getting the following error:
* About to connect() to <Private HTTPS Url> 443 (#0)
* Trying <IP Address>...
* Connected to <Private HTTPS Url> (<IP Address>) port 443 (#0)
* found 160 certificates in /etc/ssl/certs/ca-certificates.crt
* gnutls_handshake() failed: A TLS packet with unexpected length
was received.
* Closing connection 0
When using the get()-function provided by std.net.curl:
void main()
{
get("<Private HTTPS Url>");
// OR:
HTTP h = HTTP("<Private HTTPS Url>");
h.verifyHost = false;
h.verifyPeer = false;
h.verbose = true;
h.perform();
}
I'm getting a similar error:
* About to connect() to <Private HTTPS Url> port 443 (#0)
* Trying <IP Address>...
* Connected to <Private HTTPS Url> (<IP Address>) port 443 (#0)
* found 160 certificates in /etc/ssl/certs/ca-certificates.crt
* gnutls_handshake() failed: A TLS packet with unexpected length
was received.
* Closing connection 0
std.net.curl.CurlException@/home/build/tmp/build/.build/src/gcc-5.2.0/libphobos/src/std/net/curl.d(3606):
SSL connect error on handle 1C76E0
----------------
0x86363 pure @safe bool
std.exception.enforceEx!(std.net.curl.CurlException).enforceEx!(bool).enforceEx(bool, lazy immutable(char)[], immutable(char)[], uint)
/home/build/tmp/build/.build/src/gcc-5.2.0/libphobos/src/std/exception.d:546
0x79eff void std.net.curl.Curl._check(int)
/home/build/tmp/build/.build/src/gcc-5.2.0/libphobos/src/std/net/curl.d:3606
0x7be2b int std.net.curl.Curl.perform(bool)
/home/build/tmp/build/.build/src/gcc-5.2.0/libphobos/src/std/net/curl.d:3721
0x7be2b int std.net.curl.HTTP._perform(bool)
/home/build/tmp/build/.build/src/gcc-5.2.0/libphobos/src/std/net/curl.d:2234
0xee23 _Dmain
???:0
0x154e3
_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv
/home/build/tmp/build/.build/src/gcc-5.2.0/libphobos/libdruntime/rt/dmain2.d:411
0x156a7 void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).tryExec(scope void delegate())
/home/build/tmp/build/.build/src/gcc-5.2.0/libphobos/libdruntime/rt/dmain2.d:386
0x15abf void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).runAll()
/home/build/tmp/build/.build/src/gcc-5.2.0/libphobos/libdruntime/rt/dmain2.d:411
0x156a7 void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).tryExec(scope void delegate())
/home/build/tmp/build/.build/src/gcc-5.2.0/libphobos/libdruntime/rt/dmain2.d:386
0x1582f _d_run_main
/home/build/tmp/build/.build/src/gcc-5.2.0/libphobos/libdruntime/rt/dmain2.d:419
0xec8f main
???:0
0xb6d83451 __libc_start_main
???:0
I want skip the ssl-validation but it seems that curl is always
trying to verify the ssl certificate, although I think I've
disabled it by setting ssl_verifyhost and ssl_verifypeer to
false/0. I can use other ssl urls without any problems...
I'm using the latest gdc arm compiler with dmd 2.066.1
I hope anyone know what I'm doing wrong here :)