Recently I ran into an issue where my client failed to connect to our windows software after they upgraded to TLS 1.2. Reason being our application was supporting tls version < 1.2 because of .Net 4.5 . Since TLS standards keep developing and improving. At the moment TLS 1.2 is a latest encryption standard powering SSL and TLS 1.3 is under work. In general, anything that is using TLS standard below TLS 1.2 is considered to be non secure.
The solution for my problem was to upgrade my application to the latest .NET framework: 4.6.1 as in this framework version TLS 1.2 is a default cryptographic standard.
Let’s see how different versions of .Net has kind of support for TLS:
- .NET 4.6 and above. : TLS 1.2 is supported by default,You don’t need to do any additional work to support it.
- .NET 4.5. TLS 1.2 is supported, but it’s not a default protocol. You need to add code in your application to use it. The following code will make TLS 1.2 default, make sure to execute it before making a connection in your application:
- ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
- .NET 4.0. TLS 1.2 is not supported, but if you have .NET 4.5 (or above) installed on the system then you still can go for TLS 1.2 even if your application framework doesn’t support it. To do this we have to use below line of code:
For .Net 4.5 , setting securityprotocol as Tls12 does solve the issue. But if you still got any issue then try adding the below line too as I was able to connect but while fetching data facing some issue but below code line worked for me.
ws.SslConfiguration.EnabledSslProtocols = SslProtocolsExtensions.Tls12;
ws refers to a Websocketsharp.websocket instance.
Hope it helps.