【问题标题】:the request was aborted Could not a create SSL/TLS secure channel webClient C#请求被中止 无法创建 SSL/TLS 安全通道 webClient C#
【发布时间】:2019-09-10 18:38:58
【问题描述】:

大家好,我在 WebClient 中遇到问题,问题是我无法下载 使用 WebClient.downloadFile 或 WebClient.DownloadFileAsync 的特定文件 错误是 [请求中止:无法创建 SSL/TLS 安全通道],下载的文件为 0bytes 请帮助我提供任何代码 那就是下载文件或为我的问题提供建议 我的代码是:

WebClient Client = new WebClient();
Client.DownloadFile("https://github.com/MohammedZr/roepo/blob/master/x82bit/32bit.exe", @"C:\Users\MohamedAlzurghni\Desktop\Project\bolo\test\32bit.exe");

【问题讨论】:

    标签: c# .net webclient


    【解决方案1】:

    将安全协议设置为 Tls12

    System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
    WebClient Client = new WebClient();
    Client.DownloadFile("https://github.com/MohammedZr/roepo/blob/master/x82bit/32bit.exe", @"C:\Users\MohamedAlzurghni\Desktop\Project\bolo\test\32bit.exe");
    

    【讨论】:

      【解决方案2】:

      根据错误,未在 TLS 上建立连接。

      WebClient Client = new WebClient();
      Client.DownloadFile(new Uri("https://github.com/MohammedZr/enchantress/blob/master/x82bit/xmrig.exe"), @"C:\Users\MohamedAlzurghni\Desktop\Project\bolo\test\32bit.exe");
      

      您必须设置服务点使用的安全协议。

      【讨论】:

      • 感谢人的快速回答,我编辑了我的代码,现在抛出一个新错误 [请求中止,连接意外关闭],文件大小为 0 字节有什么帮助吗?非常感谢
      • 我编辑了我的评论感谢您的快速回复我真的很感激
      • 同样的问题文件大小为0字节
      • 这意味着该路径不存在文件。你会确认吗?
      • 我解决了问题是在标题中我添加了这个标题C# Client.Headers.Add("user-agent", "Mozilla"); C#
      猜你喜欢
      • 1970-01-01
      • 2012-06-05
      • 2018-04-22
      • 2012-10-30
      相关资源
      最近更新 更多