A custom remote certificate validation can be used to avoid the strict validation, instead, just make it trust anything.

In your code, simply make a call to the static method SetCertificatePolicy() once within your application before making any request to the web services.

// note this code is not intended to used 
    
// in production enviroment
    public static class Util
    {
        
/// <summary>
        
/// Sets the cert policy.
        
/// </summary>
        public static void SetCertificatePolicy()
        {
            ServicePointManager.ServerCertificateValidationCallback 
+= RemoteCertificateValidate;
        }

        
/// <summary>
        
/// Remotes the certificate validate.
        
/// </summary>
        private static bool RemoteCertificateValidate(
           
object sender, X509Certificate cert,
            X509Chain chain, SslPolicyErrors error)
        {
            
// trust any certificate!!!
            System.Console.WriteLine("Warning, trust any certificate");
            
return true;
        }
    }

 

相关文章:

  • 2021-12-16
  • 2022-02-23
  • 2021-11-28
  • 2021-07-09
  • 2022-12-23
  • 2021-04-26
  • 2021-07-10
  • 2021-06-27
猜你喜欢
  • 2021-12-19
  • 2022-12-23
  • 2021-10-23
  • 2021-10-22
  • 2021-07-29
  • 2021-09-10
  • 2022-12-23
相关资源
相似解决方案