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

那年仲夏 提交于 2019-12-20 01:52:04

问题


I am developing a Metro style app using C# and xaml.

In my application I got the error when calling to a web service:

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

What is the reason for this error?


回答1:


I have a crawler program and a few moments ago I got the same exception. The reason in my case is that the security certificate (of the site I have been crawling) expired.

A quick fix in my case was adding this line of code:

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

Note: this hack could be a security threat



来源:https://stackoverflow.com/questions/13071440/the-underlying-connection-was-closed-could-not-establish-trust-relationship-for

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!