synic synic - 7 months ago 54
C# Question

EWS and TLS 1.2 - having issues connecting automatically

One of our clients has upgraded to Tls 1.2.

However, the

client has problems connecting to it, unless I add the following code:

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

This likely won't work for all of our clients. Is there a way to make it detect which one to use automatically?


You can specify multiple supported protocols by doing something like this:

System.Net.ServicePointManager.SecurityProtocol =
    SecurityProtocolType.Ssl3 |
    SecurityProtocolType.Tls |
    SecurityProtocolType.Tls11 |

Using this sample of code, you allow all security protocols (supported by .NET).