Can we add four protocols to ServicePointManager.SecurityProtocol?

社会主义新天地 提交于 2020-01-24 10:04:26

问题


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;`

or as

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?


回答1:


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.



来源:https://stackoverflow.com/questions/38843806/can-we-add-four-protocols-to-servicepointmanager-securityprotocol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!