3

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, but https://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...

Nikola
  • 14,888
  • 21
  • 101
  • 165

3 Answers3

6

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).

C++:

setvar("WEBKIT_IGNORE_SSL_ERRORS", "1");

C#:

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.

therealmitchconnors
  • 2,732
  • 1
  • 18
  • 36
  • @therealmitchconnors: thank you for your reply (I saw your reply on the forum last night), but I can't find the referenced code you are talking about? Can you give me the link? I mean, I downloaded the src of the 0.5 version and it isn't there. Maybe it wouldn't be a bad idea to make your fix available on the net? (Since the main developer abandoned the project) – Nikola Jun 03 '11 at 06:28
  • @Nikola: if you have downloaded version 0.5 of WebKitDotNet, and openned WebKit.NET.sln in visual studio, you should see three projects - WebKitBrowser, WebKitBrowserTest, and WebKitCore. In WebKitBrowserTest, open MainForm.cs, and insert the following text between lines 48 and 49. `Environment.SetEnvironmentVariable("WEBKIT_IGNORE_SSL_ERRORS", "1");` This should make this line the first statement under `public MainForm()`, before the call to `InitializeComponent()`. Run the project, and you should be able to navigate to the site, even with a bad certificate. – therealmitchconnors Jun 07 '11 at 16:44
  • @therealmitchconnors: Thanx for your reply. I did as you said, but when I run the project and navigate to https://www.google.com I get this error: "SSL peer certificate or SSH remote key was not OK" – Nikola Jun 08 '11 at 07:40
  • @Nikola: that's not one I have seen before. It's strange that you are running the same code and getting different results... did you pull the latest version of WebKit.NET from github? – therealmitchconnors Jun 08 '11 at 17:17
  • @Nikola: try pulling down my fork of WebKitDotNet. I have modified it to ignore SSL errors by default, and have included a command line flag to (/IgnoreSSL) to enable this feature. I also modified the project file WebKitBrowserTest to use that flag by default. Try it [here](https://github.com/therealmitchconnors/webkitdotnet) and tell me what you think. I have submitted a pull request for this, so hopefully it will be merged into the master branch soon. – therealmitchconnors Jun 08 '11 at 22:57
  • @therealmitchconnors: Thank you for the github link. I have been downloading it from here originally: http://sourceforge.net/projects/webkitdotnet/. Btw, I downloaded your project and I get like 350 errors while trying to build the 2010 version (seems like references are missing - i tried to find them but no luck). Here is my screen shot http://imageshack.us/photo/my-images/819/builderrors.jpg/ so I would be gratefull if you can shed some light on this. – Nikola Jun 09 '11 at 06:23
  • @Nikola: I get the build errors too. I did not modify the solution or project reference files, so these errors are from a previous contributor. You can fix the errors by removing the references tagged with ! and then readding them. Also, you may need to rebuild the JSCore and WebKit.Interop assemblies... follow the directions [here](https://github.com/webkitdotnet/webkitdotnet/wiki/Building-WebKit.NET-with-Visual-Studio-2010-Express%3A-A-Visual-Step-By-Step-Guide). AFAIK, the github source is the latest, and the sourceforge version hasn't been updated in some time. – therealmitchconnors Jun 09 '11 at 21:33
  • Thanks! This solved my problem (1 year after the answer) in VB .NET when using WebKitBrowser! – uınbɐɥs Jul 26 '12 at 03:43
0

I tried the code below and works for me.

webkitBrowser.Preferences.IgnoreSSLErrors = true;
0

After long googling I finally ended up purchasing a SSL certificate for my domain and now all is fine. Also, a good to note is that Webkit is the easiest to work with and allows for DOM access and manipulation.

Nikola
  • 14,888
  • 21
  • 101
  • 165