How to automatically accept security certificates

2019-06-10 23:21发布

问题:

I am working on solving this problem and I'm getting caught up on the trouble of connecting to an HTTPS site without an authenticated SSL cert.

How to print formatted text from a web server with confirmation of successful printing?

When using the WebBrowser control this solution allowed me to connect.

ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);

public bool AcceptAllCertifications(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certification, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
    return true;
}

But when using the Internet Explorer Object from SHDocVw, I'm back to getting an error about the security certificate.

How can I use the Internet Explorer Object and allow connections to a site without an authenticated certificate without user input?