Csharp/C#教程:我们可以向ServicePointManager.SecurityProtocol添加四个协议吗?分享


我们可以向ServicePointManager.SecurityProtocol添加四个协议吗?

我想支持从ssl3到tls 1.2的所有安全协议。 但是在网上搜索时,我发现代码为

`ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11;` 

或者作为

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

但是,我想支持所有协议。 那么,写作是不对的

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

当我编写上面的代码时,我没有给我任何编译错误。所以,这会导致任何问题吗?

是的它会起作用。 您可以找到仅支持TLS 1.2并尝试此值的不同组合的网站,当您从值中省略SecurityProtocolType.Tls12时,您的.NET应用程序将无法连接到该网站。

上述就是C#学习教程:我们可以向ServicePointManager.SecurityProtocol添加四个协议吗?分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/943269.html

(0)
上一篇 2021年11月14日
下一篇 2021年11月14日

精彩推荐