WCF Could not establish trust relationship for the SSL/TLS Secure Channel With Authority
I saw people ask questions on the forums regarding to “Could not establish trust relationship for the SSL/TLS secure channel with authority” while attempting to call the web service via a host domain name other than the one specified in Issue-To within the SSL certificate. Most likely you are using the same certificate for the WCF web services hosted on other domains, for example, development or demo server.
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.
using System.Net; using System.Net.Security; using System.Security.Cryptography.X509Certificates; // 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; } }
引用自:http://www.codemeit.com/wcf/wcf-could-not-establish-trust-relationship-for-the-ssltls-secure-channel-with-authority.html