WebBrowser 控件 - 忽略 SSL 错误
几个小时的搜索没有找到答案。我们正在寻找一种方法,使 .NET WebBrowser 控件可以导航到存在 SSL 安全问题(自签名证书或不匹配的主机名)的页面,而无需停止并显示错误页面:
我已经看到很多接近的帖子:
如何禁用 Webbrowser 控件中的“安全警报”窗口 - - 不起作用,因为 WebBrowser 显然不使用 ServicePointManager
抑制托管 Web 浏览器控制对话框 - 取决于了解窗口标题,这对于非英语受众不起作用
C# WebBrowser Control - 忽略网站安全警告 - 这是作为重复项关闭的,答案只是引用了上面的链接。
大多数表单帖子建议实现 IInternetSecurityManager,我已经这样做了,但没有效果。
使用所有 URL 的 GetSecurityId 常量值(指定 URLZONE_LOCAL_MACHINE 或 URLZONE_TRUSTED)进行响应不起作用。
以下内容没有帮助:
public unsafe int MapUrlToZone(string url, int* pdwZone, int dwFlags)
{
*pdwZone = 3; // URLZONE_TRUSTED;
return Win32.S_OK;
}
最后,我似乎找不到使 ProcessUrlAction 产生任何效果的方法:
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 警告页面的方法吗?
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:
How to disable “Security Alert” window in Webbrowser control -- doesn't work because WebBrowser apparently doesn't use the ServicePointManager
Suppressing Hosted WebBrowser Control Dialogs -- depends on knowing window titles, which doesn't work for a non-English audience
C# WebBrowser Control - ignore website security warnings -- this was closed as a duplicate, and the answer just referred to the above link.
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.
The following doesn't help:
public unsafe int MapUrlToZone(string url, int* pdwZone, int dwFlags)
{
*pdwZone = 3; // URLZONE_TRUSTED;
return Win32.S_OK;
}
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;
}
Has anyone successfully found a way past that SSL warning page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要实现的接口是 IHttpSecurity。参见http://jiansheng .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.
对我来说,它使用以下代码工作:
希望它有用;)
For me it's working using the following code:
Hope it will be useful ;)