The request was aborted: Could not create SSL TLS secure channel.

HttpClient访问https的时候报错:

The request was aborted: Could not create SSL TLS secure channel.

这样修改:

var url = "https://...";
if (url.ToLower().StartsWith("https"))
{
	System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
}
using (var client = new HttpClient())
{
	var r = await client.GetAsync(url);
	var s = await r.Content.ReadAsStringAsync();
}
posted @ 2021-02-23 13:32  Lulus  阅读(591)  评论(0编辑  收藏  举报