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:
http://s39.radikal.ru/i085/0810/ff/7fdbb47008c9.jpg
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?
thanks in advance! Paul.
-
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.
-
bobwienholt, thank you very much!
But I've another dummy question:)
I've found sample - how to use it with WebRequest/WebResponse, but
How can I use ServicePointManager with Webbrowser control?
thanks in advance!
-
I have a solution that will suit your needs. I am in the process of writing it up as a part of a Code Project article dealing with various WebBrowser Control/SSL tricks and will let you know here when it is ready.
-
Ok, article is up on code project - see http://www.codeproject.com/KB/shell/WebBrowserControlDialogs.aspx Hopefully this helps.
-
Thanks a lot. I love you!
0 comments:
Post a Comment