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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With