Starting a HTTPS session with D

Vladimir Panteleev via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 12 04:34:20 PST 2015


On Thursday, 12 February 2015 at 12:11:27 UTC, Kadir Erdem Demir 
wrote:
> Hi
>
> We have a network traffic logger module at office.
> We need to a tool which creates simple traffic with different 
> protocols and test our product's output to see if we parse the 
> headers correctly or not.
>
> And of course I proposed writing this tool with D!!!
>
> When it comes to create a HTTP session it is very easy
>
> auto content = get("dlang.org");
>
> But I couldn't find any examples about https. Do I have to use 
> a C library like libcurl for it. Or is there a native way do 
> solve my problem.

No, you can keep using std.net.curl.

You just need to tell curl how to verify server certificates.

On Windows, if you are using the curl library included with DMD 
2.066.1, curl will use the Windows certificate store. Otherwise, 
you need to provide a trusted CA bundle:

auto http = HTTP();
http.handle.set(CurlOption.cainfo, "path/to/ca-bundle.crt");

Or, to completely disable verification:

http.handle.set(CurlOption.ssl_verifypeer, false);

Then:

get("https://dlang.org", http);


More information about the Digitalmars-d-learn mailing list