C#4.0 HTTP协议无法使用TLS1.2的问题

Posted on 2021-12-06 17:45  打杂滴  阅读(187)  评论(0)    收藏  举报

在发送HTTP请求前加入下行代码

ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;

如果是4.5以上版本可以直接使用

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3