Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make windows store app work with TLS 1.2?

There is a windows store app 8.1 connected to a web service via WCF. Recently TLS 1.2 has been set at the server and as a result the app stopped working. Here is the exception

An error occurred while making the HTTP request to https://services.companyname.com This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.

Even a simple web request

WebRequest request = WebRequest.Create(SERVER_URL_PROD);
WebResponse response = await request.GetResponseAsync();

returns the following

An exception of type 'System.Net.WebException' occurred in mscorlib.dll but was not handled in user code

Additional information: The underlying connection was closed: An unexpected error occurred on a send.

So how to make windows store app work with TLS 1.2 ?

Update

The code above works in a console app (.NET 4.5) if

 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

But ServicePointManager is not available for Windows Store apps

Update 2

Moreover the code works in Windows Phone 8.1 where ServicePointManager is not available.

like image 256
Andrei Schneider Avatar asked Jun 16 '15 12:06

Andrei Schneider


People also ask

How do you confirm TLS 1.2 is enabled?

How to check if TLS 1.2 is enabled? If the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client\DisabledByDefault is present, the value should be 0.


1 Answers

I've dealt with the TLS 1.2 issue for web applications, and as OP mentions, the simple solution for System.Net.ServicePointManager doesn't work in Windows Store apps.

The workaround is to use Windows.Web.Http instead of System.Net.Http as described in this MSDN forum posting.

like image 139
jozolo Avatar answered Oct 01 '22 03:10

jozolo