我们可以在 ServicePointManager.SecurityProtocol 中添加四个协议吗? [英] Can we add four protocols to ServicePointManager.SecurityProtocol?

查看:46
本文介绍了我们可以在 ServicePointManager.SecurityProtocol 中添加四个协议吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to support all security protocols from ssl3 to tls 1.2 . But while searching on net I either found code as

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

或作为

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

但是,我想支持所有协议.那么,写成

But, I want to support all the protocols. So, is it wrong to write as

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

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

I didn't give me any compilation errors when I wrote the above code.So, will this cause any problem?

推荐答案

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

Yes it will work. You can find a web site which only supports TLS 1.2 and try different combinations of this value, when you omit SecurityProtocolType.Tls12 from your value, your .NET app won't be able to connect to that site.

这篇关于我们可以在 ServicePointManager.SecurityProtocol 中添加四个协议吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆