https request报错 ServicePointManager.SecurityProtocol 搞定

时间:2019-11-19 13:09:41   收藏:0   阅读:459

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

发现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;

再次发送问题解决!

原文:https://www.cnblogs.com/paul010/p/11888498.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!