Default SecurityProtocol in .NET 4.5

前端 未结 17 1926
一生所求
一生所求 2020-11-22 03:24

What is the default security protocol for communicating with servers that support up to TLS 1.2? Will .NET by default, choose the highest security

17条回答
  •  南旧
    南旧 (楼主)
    2020-11-22 04:17

    Some of the those leaving comments have noted that setting System.Net.ServicePointManager.SecurityProtocol to specific values means that your app won't be able to take advantage of future TLS versions that may become the default values in future updates to .NET. Instead of specifying a fixed list of protocols, you can instead turn on or off protocols you know and care about, leaving any others as they are.

    To turn on TLS 1.1 and 1.2 without affecting other protocols:

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

    Notice the use of |= to turn on these flags without turning others off.

    To turn off SSL3 without affecting other protocols:

    System.Net.ServicePointManager.SecurityProtocol &= ~SecurityProtocolType.Ssl3;
    

提交回复
热议问题