synic synic - 1 year ago 93
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?

Answer Source

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).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download