Are you TLS 1.2 ready? Force your secure Web API to use TLS 1.2
What is TLS?
Transport Layer Security (TLS) is an industry security standard to help protect data transmitted over the internet. The newest version of TLS, 1.2 provides enhanced security and it is the current standard.
.NET Framework & TLS
The .NET framework uses common language runtime, used as an execution engine and class library providing reusable code. Older versions of .NET do not support the newer TLS 1.2 so it is recommended to also upgrade .NET to at least 4.5 if you are using an older version of Windows. The .NET 4.5 supports TLS 1.2 but it is not the default protocol so you need to opt-in to use the latest TLS 1.2.
Forcing a secure website and web API to use TLS 1.2
With the recent upgrade of TLS 1.0 and 1.1 to TLS 1.2. Older TLS 1.0 and TLS 1.1 being deprecated, So, you have to force your websites/services to run over TLS 1.2.
You will get below error due to TLS upgrade, the latest browsers by default will make a call to service (API) using TLS1.2 and API will not accept the request with new TLS version. So to fix this issue you have to force API to accept the request with new TLS 1.2 version.
GET - An unhandled exception occurred. System.InvalidOperationException: An error occurred while processing this request. ---> Microsoft.OData.Client.DataServiceTransportException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
To fix this issue you have to add below lines to global.asax
protected void Application_Start()
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
| SecurityProtocolType.Tls11
| SecurityProtocolType.Tls12;
}