阅读量:0
在工作遇到了一个关于调用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;
亲测有效。