[HTTPS] - 请求API失败(Could not create SSL/TLS secure channel)之解决
背景
在单元测试中请求 HTTPS API 失败。
异常
Result StackTrace:
at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
Result Message:
System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
解决
在请求前设置安全协议如下:
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// Use SecurityProtocolType.Ssl3 if needed for compatibility reasons
参考资料
https://stackoverflow.com/a/2904963
[HTTPS] - 请求API失败(Could not create SSL/TLS secure channel)之解决的更多相关文章
- 偶尔遇到的“The request was aborted:Could not create SSL/TLS secure channel.”怎么解决?
项目中涉及到调用第三方的Https的WebService,我使用的是原始的HttpWebRequest. 代码中已经考虑到是Https,加上了SSL3协议,加上了委托调用.但偶尔还是会碰到 The r ...
- 请求被中止: 未能创建 SSL/TLS 安全通道,以及解决方法,即:Could not create SSL/TLS secure channel
C# 访问https请求被中止: 未能创建 SSL/TLS 安全通道(Could not create SSL/TLS secure channel) 以及 X509Certificate2 temp ...
- The request was aborted: Could not create SSL/TLS secure channel
一.背景: 公司底层服务CDN从Akamai迁移到阿里云之后, 使用该服务的一个应用报错如下: System.AggregateException: One or more errors occurr ...
- 微信退款时候报”请求被中止: 未能创建 SSL/TLS 安全通道“或”The request was aborted: Could not create SSL/TLS secure channel“的错误
如题,英文中文表述的是一个意思 退款测试在我本机测试一切都是正常的,但是发布到了服务器就报这样的一个错啦 但是无论百度或者google或者bing,你能够搜索到的结果都很类似,综合起来就是加这样一些代 ...
- 【转】微信退款时候报”请求被中止: 未能创建 SSL/TLS 安全通道“或”The request was aborted: Could not create SSL/TLS secure channel“的错误
退款测试在我本机测试一切都是正常的,但是发布到了服务器就报这样的一个错啦 但是无论百度或者google或者bing,你能够搜索到的结果都很类似,综合起来就是加这样一些代码,如下 ServicePoin ...
- Could not create SSL/TLS secure channel.
解决办法: ServicePointManager.Expect100Continue = true;ServicePointManager.SecurityProtocol = SecurityPr ...
- visual studio Web发布至 IIS WebDeploy出错(未能创建SSL/TLS安全通道)Could not create SSL/TLS secure channel
问题发生的原因是VS 15.9尝试使用系统默认值进行TLS握手,但是要在VS内的某处设置为TLS1.2. 此问题的解决方法是在部署项目的IIS服务器上启用TLS 1.2.例如,请按照此文章中的说明操作
- Web Server 使用WebClient 发送https请求 The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel
使用WebClient 发送https请求 使用WebClient发送请求时,并且是以https协议: WebClient webClient = new WebClient(); string re ...
- https请求时出错:Could not establish trust relationship for the SSL/TLS secure channel
当我在用NET命名空间下获取URL的时候,提示如下错误: The underlying connection was closed: Could not establish trust relatio ...
随机推荐
- 高可用Redis:Redis Cluster
转(https://www.cnblogs.com/renpingsheng/p/9862485.html) Redis Cluster是Redis官方提供的Redis集群功能 1.为什么要实现Red ...
- Python多线程与多进程详解
进程,线程,协程https://blog.csdn.net/qq_23926575/article/details/76375337 多进程 https://www.cnblogs.com/lipij ...
- 如何监控tomcat性能:[1]工具一
| 浏览:155 | 更新:2014-12-13 10:06 1 2 3 4 5 6 分步阅读 tomcat经常被用作中间件,也有直接作WEB的,自带的工具不是很给力,推荐以下的办法 工具/原料 ja ...
- mysql innodb与myisam存储文件的区别
myisam: .frm: 存储表定义 .myd(MYData):存储数据 .MYI(MYindex):存储引擎 innodb: .frm:存储表定义 .idb:存储数据和索引,在同一个文件中
- 和重复搭建开发环境说 Bye Bye 之Vagrant
每每新同事入职,都要在自己电脑上配置一堆环境,费神费力:每每开发测试都要重新配置开发环境,手工搭建,步骤很繁琐,极易出错. 大神在时,大神搭建,大神不在,以手抚膺坐长叹.为此,VVVVVagrant横 ...
- m.baidu.com/?tn=simple 开始有广告了。。。
m.baidu.com/?tn=simple 开始有广告了.... 极简的百度也被安排上了广告,..... 文章来源:外星人来地球 欢迎关注,有问题一起学习欢迎留言.评论
- XAMPP+TestLink
XAMPP(Apache+MySQL+PHP+PERL)是一个功能强大的建站集成软件包.这个软件包原来的名字是 LAMPP,但是为了避免误解,最新的几个版本就改名为 XAMPP 了.它可以在Windo ...
- python使用post请求发送图片并接受图片
图像读取编码与反编码: import requests import json import numpy as np import cv2 import base64 # 首先将图片读入 # 由于要发 ...
- socat管理haproxy配置 ssh-keygen -N '' -t rsa -q -b 2048
socat管理haproxy配置 haproxy是可以通过socat命令管理haproxy.cfg文件的:1.安装socat yum install socat -y 2.配置haproxy.cf ...
- Docs-.NET-C#-指南-语言参考-预处理器指令:#pragma warning(C# 参考)
ylbtech-Docs-.NET-C#-指南-语言参考-预处理器指令:#pragma warning(C# 参考) 1.返回顶部 1. #pragma warning(C# 参考) 2015/07/ ...