项目中涉及到调用第三方的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;
}

  

最新文章

  1. EBS中启用OAF页面个性化三个配置
  2. COM中需要调用AddRef和Release的10条规律
  3. [ACM_几何] Wall
  4. JSON.parse()和JSON.stringify()(转载)
  5. 【转】PaxosLease算法--2PC看Paxos选主
  6. struts2项目需要加入的jar包
  7. .Net之一般处理程序
  8. scala 函数编程
  9. Paypal-Express Checkout快捷支付方式的android端开发心得(二)
  10. Struts2之环境配置
  11. Ubuntu12.04下Django1.4的删除目录
  12. css中,在高度已知,写出三栏布局,其中左栏、右栏宽度各位300px,中间自适应
  13. python初学心得之一
  14. POJ 3580-SuperMemo-splay树
  15. 多个SDK控制管理
  16. Windows7下安装redmine-3.4.6
  17. Lua 与 C 交互之UserData(4)
  18. ACDsee的安装过程
  19. Java程序员面试中的多线程问题1
  20. eclipse添加缺失的包/src/main/resource

热门文章

  1. 使用Python的Flask框架,结合Highchart,动态渲染图表(Ajax 请求数据接口)
  2. 5 pandas模块,DataFrame类
  3. ThinkPHP5 自定义异常
  4. Linux进程线程学习笔记:运行新程序
  5. [poj1062]昂贵的聘礼_最短路_离散化
  6. 洛谷——P1106 删数问题
  7. iOS:如何让xib同时兼容支持iOS6和iOS7
  8. Swoole源代码学习记录(十二)——ReactorThread模块
  9. php循环,die/exit脚本执行控制,文件载入及错误控制
  10. SharePoint 2013 改动表单认证登录页面