(转自:http://blog.sina.com.cn/s/blog_5eca668b01018949.html)
定义一个类,来对远程X.509证书的验证,进行处理,返回为true.我们要自己定义一个类,然后在客户单调用WCF服务之前,执行一次即可。代码如下:

 
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; }
}

 

     你要在调用操作点先调用这个方法: Util.SetCertificatePolicy();

相关文章:

  • 2021-08-12
  • 2022-12-23
  • 2022-02-02
  • 2022-12-23
  • 2021-07-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-21
  • 2022-12-23
  • 2021-09-25
  • 2022-12-23
相关资源
相似解决方案