+
80
-

c#中HttpWebRequest出错请求被中止: 未能创建 SSL/TLS 安全通道?

c#中HttpWebRequest出错请求被中止: 未能创建 SSL/TLS 安全通道?

网友回复

+
0
-

需要指定ssl证书

引用:using System.Net;

在请求之前插入TLS安全协议:System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

代码如下:

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
 HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create(url);// 打开网络连接

我知道答案,我要回答