使用webclient从https下载文件时出错

我创建了一段代码,使用WebClient从给定的URL下载文件。

问题是当代码尝试从HTTPS站点下载文件时,我收到以下错误。

 The remote certificate is invalid according to the validation procedure 

此问题仅发生在不在本地计算机上的服务器上,因此我也不知道如何调试它。

我在网上看了几个答案,但没有找到任何可以帮助我的东西。

这段代码:

  using (WebClient Client = new WebClient()) { string fileName = System.Configuration.ConfigurationManager.AppSettings["siteUploadedDirectory"] + "/temp/" + Context.Timestamp.Ticks.ToString() + "_" + FileURL.Substring(FileURL.LastIndexOf('/')+1); fileName = Server.MapPath(fileName); Client.DownloadFile(FileURL, fileName); return fileName + "|" + FileURL.Substring(FileURL.LastIndexOf('/')+1); } 

我正在尝试的url:

 http://Otakim.co.il/printreferrer.aspx?ReferrerBaseURL=cloudents.com &ReferrerUserName=ram &ReferrerUserToken=1 &FileURL=https://www.cloudents.com/d/lzodJqaBYHu/pD0nrbAtHSq 

文件URL:FileURL = https://www.cloudents.com/d/lzodJqaBYHu/pD0nrbAtHSq

任何帮助将不胜感激

您可以通过以下代码snieppet绕过证书validation过程

  ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;