如何禁用“安全警报"浏览器控件中的窗口 [英] How to disable "Security Alert" window in Webbrowser control
本文介绍了如何禁用“安全警报"浏览器控件中的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Webbrowser 控件以不受信任的证书"登录到 HTTPS 站点.但我弹出这样的标准窗口安全警报"关于不受信任的证书:
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:
我必须按标题找到这个窗口并将其发送Alt+Y按是:
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.
如何忽略此警报?
或者在 Webbrowser 控件中禁用这个不受信任的证书"检查?
How can I ignore this alert?
Or disable this "untrusted certificate" check in Webbrowser control?
推荐答案
应该这样做:
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.
这篇关于如何禁用“安全警报"浏览器控件中的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文