c# - ServicePointManager.SecurityProtocol 是如何工作的?

标签 c#

我想知道当我在她的标志上设置三个不同的 SecurityProtocolType 时属性 ServicePointManager.SecurityProtocol 是如何工作的。即:

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

通信是否会首先尝试与 TLS 通信,如果失败则尝试 TLS1.2 并在 SSL3 之后尝试?

如果不是,这些标志是什么意思,它是如何工作的?

最佳答案

无论您使用哪个通信对象(HttpClient、HttpWebRequest 等)都将尝试首先协商到最高级别。否则它将继续“向下”链。

如果您使用的是 .Net 4.6,那么默认安全协议(protocol)将如下所示,因为 SSL3 已损坏:

SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12

如果您出于某种原因确实需要使用 SSL3 并且正在使用 .Net 4.6,请参阅这篇 MS 知识库文章,了解如何强制其不安全:https://support.microsoft.com/en-us/kb/3069494

您可能还会问这个协议(protocol)级别实际上是如何确定的?这是 SSL 握手过程的第 1 步,连接的每一端都说“我支持这个版本”。这是关于完整握手过程的有趣读物:http://www.truedigitalsecurity.com/blog/2015/05/20/ssltls-protocol-version-negotiation/

关于c# - ServicePointManager.SecurityProtocol 是如何工作的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37925001/

相关文章:

c# - 在经过 Window 身份验证的 Intranet 站点中允许未经身份验证的 ASP.NET MVC 3 用户

C# 读取西里尔字母

c# - Reactive Throttle 返回在 TimeSpan 内添加的所有项目

c# - 使用 WPF 客户端和 Active Directory ADFS 对 Cloud NodeJS 后端进行身份验证

c# - 在日期中设置特定的一天

c# - 在 ASP.NET 中 5 秒后重置表单和页面状态

C# 单元测试异步错误

c# - 使用托管 C++ 项目中的 C# 类

c# - 组中 ListView 项的索引

c# - Convert.ToString(Decimal, IFormatProvider) 或 String.Format