偶尔遇到的“The request was aborted:Could not create SSL/TLS secure channel.”怎么解决?
2024-10-21 10:04:22
项目中涉及到调用第三方的Https的WebService,我使用的是原始的HttpWebRequest。
代码中已经考虑到是Https,加上了SSL3协议,加上了委托调用。但偶尔还是会碰到
The request was aborted:Could not create SSL/TLS secure channel.
这样的错误。
于是根据这篇博客所说,将其改成使用Tls协议,看看有没有用。
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))///https请求
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; //SSL3协议替换成TLS协议
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
webRequest = WebRequest.Create(url) as HttpWebRequest;
webRequest.ProtocolVersion = HttpVersion.Version10;
}
else
{
webRequest = WebRequest.Create(url) as HttpWebRequest;
}
最新文章
- EBS中启用OAF页面个性化三个配置
- COM中需要调用AddRef和Release的10条规律
- [ACM_几何] Wall
- JSON.parse()和JSON.stringify()(转载)
- 【转】PaxosLease算法--2PC看Paxos选主
- struts2项目需要加入的jar包
- .Net之一般处理程序
- scala 函数编程
- Paypal-Express Checkout快捷支付方式的android端开发心得(二)
- Struts2之环境配置
- Ubuntu12.04下Django1.4的删除目录
- css中,在高度已知,写出三栏布局,其中左栏、右栏宽度各位300px,中间自适应
- python初学心得之一
- POJ 3580-SuperMemo-splay树
- 多个SDK控制管理
- Windows7下安装redmine-3.4.6
- Lua 与 C 交互之UserData(4)
- ACDsee的安装过程
- Java程序员面试中的多线程问题1
- eclipse添加缺失的包/src/main/resource
热门文章
- 使用Python的Flask框架,结合Highchart,动态渲染图表(Ajax 请求数据接口)
- 5 pandas模块,DataFrame类
- ThinkPHP5 自定义异常
- Linux进程线程学习笔记:运行新程序
- [poj1062]昂贵的聘礼_最短路_离散化
- 洛谷——P1106 删数问题
- iOS:如何让xib同时兼容支持iOS6和iOS7
- Swoole源代码学习记录(十二)——ReactorThread模块
- php循环,die/exit脚本执行控制,文件载入及错误控制
- SharePoint 2013 改动表单认证登录页面