错误与下载使用WebClient的HTTPS文件

编程入门 行业动态 更新时间:2024-10-25 20:31:22
本文介绍了错误与下载使用WebClient的HTTPS文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已创建了一块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); }

我努力的网址:

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

文件网址:FileURL = www.cloudents/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文件

本文发布于:2023-11-12 01:30:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580130.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:下载使用   错误   文件   WebClient   HTTPS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!