Is that possible to send HttpWebRequest using TLS1.2 on .NET 4.0 framework

gene picture gene · Jun 16, 2016 · Viewed 79.2k times · Source

My application connects to Experian server and Experian will soon stop supporting TLS 1.0 and TLS 1.1. All connectivity using HTTPS must use TLS Version 1.2.

I want to do some research on that issue and see sending HttpWebRequest using TLS 1.2 on .NET 4.0 framework works

If it does not, I will probably need to create a webservice on .NET 4.5 and call its methods, if it does, I do not have to anything.

Has anyone already faced with that issue?

Answer

Crowcoder picture Crowcoder · Jun 16, 2016

Yes, it supports it but you must explicitly set the TLS version on the ServicePointManager. Just have this code run anytime (in same app domain) before you make the call to Experian:

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

Update

see @iignatov 's answer for what you must do for framework v4.0. My code works with 4.5+