我们可以向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应用程序将无法连接到该网站。