WebBrowser 控件 - 忽略 SSL 错误 [英] WebBrowser control - ignore SSL errors
问题描述
许多小时的搜索都没有得到答案.我们正在寻找一种方法,使 .NET WebBrowser 控件可以导航到具有 SSL 安全问题(自签名证书或不匹配的主机名)的页面,而无需停止和显示错误页面:
Many hours of searching has not lead to an answer. We're looking for a way that a .NET WebBrowser control can navigate to pages with SSL security problems (self-signed certificates or non-matching hostnames) without stopping and displaying the error page:
我已经看过很多接近的帖子:
I've already seen many posts that are close:
如何禁用 Webbrowser 控件中的安全警报"窗口 -- 不起作用,因为 WebBrowser 显然不使用 ServicePointManager
How to disable "Security Alert" window in Webbrowser control -- doesn't work because WebBrowser apparently doesn't use the ServicePointManager
抑制托管 WebBrowser 控制对话框 -- 取决于了解窗口标题,这不适用于非英语观众
Suppressing Hosted WebBrowser Control Dialogs -- depends on knowing window titles, which doesn't work for a non-English audience
C# WebBrowser Control - 忽略网站安全警告 - 这已作为重复关闭,答案只是参考了上面的链接.
C# WebBrowser Control - ignore website security warnings -- this was closed as a duplicate, and the answer just referred to the above link.
大多数表单帖子都建议实施 IInternetSecurityManager,我已经这样做了,但无济于事.
使用所有 URL 的 GetSecurityId 常量值(指定 URLZONE_LOCAL_MACHINE 或 URLZONE_TRUSTED)响应不起作用.
Most form posts suggest implementing IInternetSecurityManager, which I've done, but to no avail.
Responding with a constant value for GetSecurityId for all URLs (specifying URLZONE_LOCAL_MACHINE or URLZONE_TRUSTED) doesn't work.
以下没有帮助:
public unsafe int MapUrlToZone(string url, int* pdwZone, int dwFlags)
{
*pdwZone = 3; // URLZONE_TRUSTED;
return Win32.S_OK;
}
最后,我似乎找不到让 ProcessUrlAction 产生任何效果的方法:
Finally, I can't seem to find a way for ProcessUrlAction to have any effect:
public unsafe int ProcessUrlAction(string url, int dwAction, byte* pPolicy, int cbPolicy,
byte* pContext, int cbContext, int dwFlags, int dwReserved)
{
*((int*)pPolicy) = (int)Win32.UrlPolicy.URLPOLICY_ALLOW;
return Win32.S_OK;
}
有没有人成功找到绕过 SSL 警告页面的方法?
Has anyone successfully found a way past that SSL warning page?
推荐答案
你需要实现的接口是 IHttpSecurity.见http://jiangsheng.net/2013/07/17/howto-ignoring-web-browser-certificate-errors-in-webbrowser-host/ 基于 Windows 窗体的示例.
the interface you need to implement is IHttpSecurity. See http://jiangsheng.net/2013/07/17/howto-ignoring-web-browser-certificate-errors-in-webbrowser-host/ for an example based on Windows Forms.
这篇关于WebBrowser 控件 - 忽略 SSL 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!