赞
踩
在工作遇到了一个关于调用webapi接口的问题,特此记录下来。
本地调试,调用接口都OK。但是放到服务器上调用。就一直报The request was aborted: Could not create SSL/TLS secure channel.这个错误。
解决办法:在HttpWebRequest前以下设置代码
- ServicePointManager.Expect100Continue = true;
- ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
- ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;
亲测有效。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。