简体   繁体   English

调用网络服务时,是否可以在.net中使用TLS 1.2或1.1(如果1.2不可用)?

[英]Can I use TLS 1.2 or 1.1 (if 1.2 is not available) in .net when calling a web servivce?

I would like to be able to use TLS 1.2, if a web service requires it, but also (for the time being) make calls using TLS 1.1 to services that do not support it. 我希望能够使用TLS 1.2(如果Web服务需要它),而且(暂时)还可以使用TLS 1.1向不支持它的服务进行呼叫。

Currently we are using ServicePointManager.SecurityProtocol to set this in our code. 当前,我们正在使用ServicePointManager.SecurityProtocol在我们的代码中进行设置。 (.net 4.0) Is this already backwards compatible? (.net 4.0)这是否已经向后兼容? Or is it an all or nothing thing? 还是全有还是全无? And if so, is there some way to OR things together? 如果是这样,是否有某种方法可以对事物进行“或”运算?

您可以使用按位或作为SecurityProtocolType是flag attribute来指定多个TLS。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM