Tuesday, March 16, 2010

Could not establish trust relationship for the SSL/TLS secure

System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

I ran into this problem recently, I decided to post the solution that I found.
My specific problem stemmed from SSL Certification expired.
You can find more reasons that can cause this problem are at http://support.microsoft.com/kb/915599

When you try to connect a server with expired certificate SSL, .NET raises an exception.
To work around this problem, perform the following:


System.Net.ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(delegate { return true; });


NOTE: Once you change this property, the change applies to all requests on the system.


Hope this help,
The Liquid.

No comments:

Post a Comment