如何禁用"安全警报"窗口WebBrowser控件中 [英] How to disable "Security Alert" window in Webbrowser control

查看:288
本文介绍了如何禁用"安全警报"窗口WebBrowser控件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用WebBrowser控件登录到HTTPS站点不受信任的证书。
但我得到这样的弹出窗口非标准安全警报关于不受信任的证书:

我按标题找到这个窗口,并将其发送<大骨节病>替代 + <大骨节病>是至preSS的的:

  INT iHandle = NativeWin32.FindWindow(NULL,安全警报);
NativeWin32.SetForegroundWindow(iHandle);
System.Windows.Forms.SendKeys.Send(Y%);

但用户可以看到此窗口的闪烁。<​​/ P>

我怎么能忽视这个警告?结果
或WebBrowser控件中禁用此不受信任的证书检查?


解决方案

这应该这样做:

 公共静态布尔ValidateServerCertificate(对象发件人,X509证书证书,X509Chain链,SslPolicyErrors sslPolicyErrors)
{
    返回true;
}ServicePointManager.ServerCertificateValidationCallback =新RemoteCertificateValidationCallback(ValidateServerCertificate);

显然,令人眼花缭乱允许证书是一个安全隐患。要小心。

I'm using Webbrowser control to login to HTTPS site with "untrusted certificate". but I get popup such standart window "Security Alert" about untrusted certificate:

I have to find this window by title and send it Alt+Y to press Yes:

int iHandle = NativeWin32.FindWindow(null, "Security Alert");
NativeWin32.SetForegroundWindow(iHandle);
System.Windows.Forms.SendKeys.Send("Y%");

but user can see a flickering of this window.

How can I ignore this alert?
Or disable this "untrusted certificate" check in Webbrowser control?

解决方案

This should do it:

public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
    return true;
}

ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);

Obviously, blindingly allowing certificates is a security risk. Be careful.

这篇关于如何禁用&QUOT;安全警报&QUOT;窗口WebBrowser控件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆