Where to place RemoteCertificateValidationCallback?

后端 未结 3 1453
忘了有多久
忘了有多久 2020-12-20 05:59

I have the same problem as here: How to disable "Security Alert" window in Webbrowser control

I like the answer, but where am I going to place the Se

3条回答
  •  醉话见心
    2020-12-20 06:52

    Try this:

    private static bool ValidateRemoteCertificate(
      object sender,
      X509Certificate certificate,
      X509Chain chain,
      SslPolicyErrors policyErrors)
    {
        // Logic to determine the validity of the certificate
         // return boolean
    }
    
    
    // allows for validation of SSL conversations
                ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(
                    ValidateRemoteCertificate
                );
    
    HtmlElementCollection ellements = webBrowser.Document.GetElementsByTagName("input");
    foreach (HtmlElement ellement in ellements)
    {
        if (ellement.OuterHtml == "")
        {
            ellement.InvokeMember("click");
            this.DialogResult = DialogResult.OK;
            break;
        }
    }
    

提交回复
热议问题