https request报错 ServicePointManager.SecurityProtocol 搞定


  突然被同事反馈无法正常发送对应信息,赶紧差错!

发现request请求API接口均报 请求被中止: 未能创建 SSL/TLS 安全通道 非常奇怪,

于是查询环境Framework版本4.0 升级至4.8 故障依旧

查询代码发现需要设置一下ServicePointManager.SecurityProtocol这个类下面的几个枚举属性如下

public enum SecurityProtocolType
{
Ssl3 = 48,
Tls = 192,
Tls11 = 768,
Tls12 = 3072,
}

于是设置  ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;

再次发送问题解决!


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM