WebBrowser 控件 - 忽略 SSL 错误

发布于 2024-11-27 13:05:05 字数 1503 浏览 5 评论 0原文

几个小时的搜索没有找到答案。我们正在寻找一种方法,使 .NET WebBrowser 控件可以导航到存在 SSL 安全问题(自签名证书或不匹配的主机名)的页面,而无需停止并显示错误页面:

http://imgur.com/Uqt7H

我已经看到很多接近的帖子:

如何禁用 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:

http://imgur.com/Uqt7H

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦萦几度 2024-12-04 13:05:05

您需要实现的接口是 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.

清风不识月 2024-12-04 13:05:05

对我来说,它使用以下代码工作:

' automatically accept HTTPS certificates
ServicePointManager.ServerCertificateValidationCallback = AddressOf AcceptAllCertifications

希望它有用;)

For me it's working using the following code:

' automatically accept HTTPS certificates
ServicePointManager.ServerCertificateValidationCallback = AddressOf AcceptAllCertifications

Hope it will be useful ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文