C# – How to programmatically answer “Yes” to WebBrowser control security alert

cwebbrowser-controlwinforms

I am using WebBrowser control to programmatically access a single website, but whenever I login, I receive this certificate security alert:

enter image description here

Since I trust that website and since I need to programmatically automate the login as well, this dialog box gets in the way.

I searched SO for a solution and found a question similar to mine, but the accepted answer does not work!

I defined a static member in the form that contains the WebControl:

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

In my form's constructor I added:

ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);

But that didn't get rid of the certificate security alert.

I also, clicked the View Certificate button, then clicked the Install Certificate button in the dialog that followed, but that didn't seem to help either.

Is there any way to get rid of this warning?

Is there an IE equivalent to Firefox's Add Security Exception‌​?

Note: The owner's certificate works perfectly fine (without exhibiting this security alert) with standalone browsers (IE, FF, Chrome, Safari). It only exhibits the problem with the WebBroswer control.

Best Answer

ScriptErrorsSuppressed = True doesn't help: the security dialog does not appear, but the effect is like pressing "No"

Related Topic