Webkitdotnet unable to load https site

时光总嘲笑我的痴心妄想 提交于 2020-01-13 05:12:12

问题


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


回答1:


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.




回答2:


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.




回答3:


I tried the code below and works for me.

webkitBrowser.Preferences.IgnoreSSLErrors = true;


来源:https://stackoverflow.com/questions/5579631/webkitdotnet-unable-to-load-https-site

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!