stil / CurlThin

Lightweight cURL wrapper for C# with support for curl_multi polling interface through libuv
Other
68 stars 18 forks source link

SSL_CACERT when trying to do an https GET #8

Closed MeisterLone closed 6 years ago

MeisterLone commented 6 years ago

Hi

I dont get a response other than "SSL_CACERT" when I try to make an https call. What am I doing wrong? TY!

CurlNative.Easy.SetOpt(easy, CURLoption.URL, "https://www.cloudflare.com");
//CurlNative.Easy.SetOpt(easy, CURLoption.HTTP_VERSION, 2);

var stream = new MemoryStream();
CurlNative.Easy.SetOpt(easy, CURLoption.WRITEFUNCTION, (data, size, nmemb, user) =>
{
    var length = (int)size * (int)nmemb;
    var buffer = new byte[length];
    Marshal.Copy(data, buffer, 0, length);
    stream.Write(buffer, 0, length);
    return (UIntPtr)length;
});

var result = CurlNative.Easy.Perform(easy);
stil commented 6 years ago

You need to set CURLOPT_CAINFO option so SSL certificates can be correctly verified.

CurlNative.Easy.SetOpt(easy, CURLoption.CAINFO, CurlResources.CaBundlePath);
MeisterLone commented 6 years ago

It ended up being the system proxy that it tried to use. (Running a sniffing proxy in the background). I added curlopts to disable ssl verify while im using the proxy.

Thanks for the effort you put into this project. It works perfectly! I have a multithreaded test running doing thousands of requests per second.