WCF Could not establish trust relationship for the SSL/TLS secure channel with authority
2011-04-19 14:13
519 查看
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;
}
}
// 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;
}
}
相关文章推荐
- WCF分布式开发常见错误(24):Could not establish trust relationship for the SSL/TLS secure channel with authority(转)
- “Could not establish trust relationship for the SSL/TLS secure channel with authority”
- WCF分布式开发常见错误(24):Could not establish trust relationship for the SSL/TLS secure channel with authority
- https请求时出错:Could not establish trust relationship for the SSL/TLS secure channel
- Could not establish trust relationship for the SSL/TLS secure channel
- [bug]The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
- EX:The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
- The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure
- The underlying connection was closed:Could not establish trust relationship for the SSL/TLS secure
- The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure
- 关于解决 请求被中止:无法建立SSL / TLS安全通道(The request was aborted: Could not create SSL/TLS secure channel)的问题
- 偶尔遇到的“The request was aborted:Could not create SSL/TLS secure channel.”怎么解决?
- The request was aborted: Could not create SSL/TLS secure channel.
- WCF分布式开发常见错误(24):the SSL/TLS secure channel with authority
- SSL HttpWebRequest in C# "Could not create SSL/TLS secure channel
- 请求被中止: 未能创建 SSL/TLS 安全通道,以及解决方法,即:Could not create SSL/TLS secure channel
- 解决For compliance with existing applications not using SSL the verifyServerCertificate property
- weblogic报错----Received exception while creating connection for pool "TDMSKD": The Network Adapter could not establish the connection
- WCF分布式开发常见错误(27):Secure channel cannot be opened because security negotiation with the remote endpoint has failed