我想知道当我在她的标志上设置三个不同的 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/