错误与下载使用WebClient的HTTPS文件 [英] Error with download a file from https using webclient
问题描述
我已创建了一块code的,使用Web客户端从一个给定的URL下载文件。
I have create a piece of code that download a file from a given URL using WebClient.
问题是我收到的时候code试图下载从 HTTPS
网站文件下面的错误。
The problem is i am getting the following error when the code is trying to download a file from a HTTPS
site.
The remote certificate is invalid according to the validation procedure
这个问题只发生在服务器不在本地机器上,所以我也不知道该怎么调试。
This issue happened only on the server not on the local machine, so i also don't know how to debug it.
我看了网络上的几个答案,但没有发现任何可以帮助我。
I have read several answers on the web but didn't find anything that could help me.
这件作品code的:
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);
}
我努力的网址:
http://Otakim.co.il/printreferrer.aspx?ReferrerBaseURL=cloudents.com
&ReferrerUserName=ram
&ReferrerUserToken=1
&FileURL=https://www.cloudents.com/d/lzodJqaBYHu/pD0nrbAtHSq
文件网址:
FileURL = https://www.cloudents.com/d/lzodJqaBYHu/pD0nrbAtHSq
任何帮助将AP preciated
Any help will be appreciated
推荐答案
您可以通过以下code snieppet绕过证书验证过程
You can bypass the certificate validation process by following code snieppet
ServicePointManager.ServerCertificateValidationCallback
+= (sender, certificate, chain, sslPolicyErrors) => true;
这篇关于错误与下载使用WebClient的HTTPS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!