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

后端 未结 5 2009
遇见更好的自我
遇见更好的自我 2021-02-05 05:35

I have a simple app that uses the C# Web Client class to download a websites HTML. This is a stripped down sample of the code I\'m using:

WebClient wc = new Web         


        
5条回答
  •  一向
    一向 (楼主)
    2021-02-05 06:24

    According to this Answer, add this line before using WebClient instance:

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

提交回复
热议问题