简体   繁体   English

请求已中止:无法创建SSL / TLS安全通道

[英]request was aborted: Could not create SSL/TLS secure channel

Im exploring a system of applications i have not built and that doesnt have any documentation. 我正在探索一个我尚未构建的应用程序系统,该系统没有任何文档。 Im trying to make an api request from it that fails. 我试图从它发出一个api请求失败。 Iver tried two different ways one with Microsofts HttpClient and the other try is with the RestSharp librabry. Iver尝试了两种不同的方法,一种是使用Microsoft的HttpClient,另一种是使用RestSharp librabry。 Both work when i run them outside of the application. 当我在应用程序外部运行它们时,它们都可以工作。 From CH Fiddler onlie or a test application that i create just to debug. 从CH Fiddler onlie或我创建的用于调试的测试应用程序开始。

What can there be in the application that stops the call and why? 应用程序中可以停止呼叫的原因是什么?为什么?

The error i get: 我得到的错误:

WebException: The request was aborted: Could not create SSL/TLS secure channel. WebException:请求已中止:无法创建SSL / TLS安全通道。

Method one: 方法一:

  var client = new HttpClient();
        var clientResponse = client.GetStringAsync("https://xkcd.com/info.0.json").Result;
        var clientJson = JsonConvert.DeserializeObject<dynamic>(clientResponse);
        var imgUrl = clientJson.img;

Method two 方法二

    var restClient = new RestClient();
        restClient.BaseUrl = "https://xkcd.com";

        var request = new RestRequest();
        request.Resource = "/info.0.json";

        var response = restClient.Execute<dynamic>(request);

        // json["alt"] json["img"] eller json.img
        var json = JsonConvert.DeserializeObject<dynamic>(response.Content);
        var x = json.img;

The application runs net 4.5. 该应用程序运行net 4.5。

您也可以在执行任何请求之前添加此行

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WebException:请求已中止:无法创建SSL / TLS安全通道 - WebException: The request was aborted: Could not create SSL/TLS secure channel HttpWebRequest:请求已中止:无法创建SSL / TLS安全通道 - HttpWebRequest: The request was aborted: Could not create SSL/TLS secure channel 请求被中止:无法创建 SSL/TLS 安全通道 - The request was aborted: Could not create SSL/TLS secure channel Braintree 中的“请求被中止:无法创建 SSL/TLS 安全通道”错误 - "The request was aborted: Could not create SSL/TLS secure channel" error in Braintree RestSharp 请求中止 - 无法创建 SSL/TLS 安全通道 - RestSharp request aborted - could not create SSL/TLS secure channel 该请求已中止:无法为HttpWebRequest创建SSL / TLS安全通道 - The request was aborted: Could not create SSL/TLS secure channel for HttpWebRequest IIS 2019:请求被中止:无法创建 SSL/TLS 安全通道 - IIS 2019: The request was aborted: Could not create SSL/TLS secure channel 请求已中止:无法创建 SSL/TLS 安全通道 - The request was aborted: Could not create SSL/TLS secure channel 该请求已中止:无法创建SSL / TLS安全通道。 调用PostAsJsonAsync时 - The request was aborted: Could not create SSL/TLS secure channel. when calling PostAsJsonAsync 该请求已中止:无法创建SSL / TLS安全通道。 用于HttpWebRequest和WebClient - The request was aborted: Could not create SSL/TLS secure channel. for HttpWebRequest and WebClient
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM