Webkitdotnet unable to load https site

profile for Nikola at Stack Overflow, Q&A for professional and enthusiast programmers
I’m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%). In this category (stackoverflow) of posts I will will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread here.

My quesiton was:

I am using this webkitdotnet in my C# project. It all went well until I had to use access site with https.

I’ve searched their forum and found few posts about this but none of it solves my problem, so please shed some light on this one. Thx!

edit: Also as mentioned in their threads (also without an answer) I get a “Peer certificate cannot be authenticated with known CA certificates” error when trying to access my server, buthttps://www.google.com works fine.

They also mention the “apple” build which worked fine with ssl (at least so they say), but I can’t find it anywhere…

The answer, by therealmitchconnors, was:

This is a bit of a hack, but you can make webkitdotnet ingore peer ssl errors. WebKitDotNet uses WebKit, which, in turn uses curl, which is responsible for your wonderful ssl error there. curl exposes an option to ignore ssl errors, but neither webkit nor webkitdotnet seem to expose this functionality in their api. However, if you checkout the webkit source code, webkit sets the curl option (CURLOPT_SSL_VERIFYPEER) to false if the value of the environment variable WEBKIT_IGNORE_SSL_ERRORS is set to true.

What this all boils down to is that if you set the environment variable in code before initializing either webkit or webkitdotnet components, webkit will ignore the bad certificate and allow you to navigate to the site (sort of like clicking Proceed Anyway on IE9’s Bad Certificate Warning page).




Environment.SetEnvironmentVariable("WEBKIT_IGNORE_SSL_ERRORS", "1");

If anyone is interested, the webkit source code referenced is in file webkit\Source\WebCore\platform\network\curl\ResourceHandleManager.cpp at lines 65 and 681, currently.

Written by Nikola Brežnjak