电脑桌面
添加蚂蚁七词文库到电脑桌面
安装后可以在桌面快捷访问

【常见问题】请求被中止: 未能创建 SSL/TLS 安全通道。

来源:金蝶云社区作者:金蝶2024-09-235

【常见问题】请求被中止: 未能创建 SSL/TLS 安全通道。

```csharp 问题描述: 今天用HttpWebRequest类Post请求https的接口,报错:请求被中止: 未能创建 SSL/TLS 安全通道。 解决方法: 参考如下函数, 在创建HttpWebRequest实例之前,加上 ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; public static string PostData(byte[] data, string url, string contentType = "application/json", int timeout = 20) { //创建httpWebRequest对象 HttpWebRequest httpRequest = null; if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase)) { ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true; ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; httpRequest = WebRequest.Create(url) as HttpWebRequest; httpRequest.ProtocolVersion = HttpVersion.Version10; } else { httpRequest = WebRequest.Create(url) as HttpWebRequest; } if (httpRequest == null) { throw new ApplicationException(string.Format("Invalid url string: {0}", url)); } //填充httpWebRequest的基本信息 httpRequest.ContentType = contentType; httpRequest.Method = "POST";

【常见问题】请求被中止: 未能创建 SSL/TLS 安全通道。

```csharp问题描述: 今天用HttpWebRequest类Post请求https的接口,报错:请求被中止: 未能创建 SSL/TLS 安全通道。解决方法: 参考如...
点击下载文档文档为doc格式

声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

已经是第一篇
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息
QQ群
  • 答案:my7c点击这里加入QQ群
支持邮箱
微信
  • 微信