当前位置:   article > 正文

WCF Could not establish trust relationship for the SSL/TLS secure channel with authority

wcf state=opened了但是could not establish trust relationship
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 ;
        }
    }

 

转载于:https://www.cnblogs.com/sayo/archive/2011/04/19/2020846.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/847934
推荐阅读
相关标签
  

闽ICP备14008679号