Search

Ignore Invalid HTTPS certificate

To ignore invalid HTTPS certicates calling HTTPS Web service (for example), it is necessary to implement a dummy callback for the ServicePointManager:

using System.Net;
...
 
   ServicePointManager.ServerCertificateValidationCallback =
      new RemoteCertificateValidationCallback
         (IgnoreCertificateErrorHandler);
...
private bool IgnoreCertificateErrorHandler
   (object sender,
   System.Security.Cryptography.X509Certificates.X509Certificate certificate,
   System.Security.Cryptography.X509Certificates.X509Chain chain,
   System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
 
   return true;
}
...