WCF Service TLS 1.2 Enforcement - wcf

We are trying to enforce TLS 1.2 in our WCF Service.
We have our WCF Service hosted on IIS on our VM Boxes.
We are not sure how to disable TLS 1.0 and TLS 1.1 for our service.
We have tried the following approach:
Configuration change in our WCF Service (Server side) and (client side)** –
For the client side, we added the following code in our main method –
Remove insecure protocols (SSL3, TLS 1.0, TLS 1.1)
ServicePointManager.SecurityProtocol &= ~SecurityProtocolType.Ssl3;
ServicePointManager.SecurityProtocol &= ~SecurityProtocolType.Tls;
ServicePointManager.SecurityProtocol &= ~SecurityProtocolType.Tls11;
// Add TLS 1.2, 1.3
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls13;
We have verified that this works on the client side, i.e., the client uses only TLS 1.2 to send requests after this config.
But the same configuration on our Server side WCF service does not work.
We have written this config change inside global.asax file inside Application_Start method for our
server, but the WCF Service hosted on IIS Server still accepts TLS 1.0/1.1 requests.
We have tried another method where we did registry key changes on Windows Server to disable TLS 1.0, TLS 1.1 for the whole VM box.
The blocker for going with this method is that there are many other services on our VM,
which might get affected if we do a configuration change on the whole server.
Is there any working method wherein we change the configuration of our WCF Service to disable serving TLS 1.0/1.1 requests on the service level?
Any help would be appreciated. :-)

At first, we had better not specify the TLS version manually, just let the OS decide on the TLS version. Please check the official document of TLS best practices.
https://learn.microsoft.com/en-us/dotnet/framework/network-programming/tls
Provided that OS and project’s SDK support TLS1.2(it needs prerequisites, Dotnet4.6.1+,win7+),We could specify the TLS version used during the communication by the below code on the client-side.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServiceReference1.ServiceClient client = new ServiceReference1.ServiceClient();
Besides, modifying the Windows registry can disable certain version protocols.
Please refer to the below link.
https://serverfault.com/questions/733994/how-to-disable-tls-1-0-in-windows-2012-rdp
https://learn.microsoft.com/en-us/windows-server/security/tls/tls-registry-settings
Feel free to let me know if there is anything I can help with.

Related

The caller was not authenticated by the service when tls1.0 is disabled

using c# i have two aplications
on .net framework 4 - client
and one more on .net framework 4.5 - server
and communicate each other using WCF.
using IISCrypto i turned off tls1.0 and then i get this error
'The caller was not authenticated by the service'
i know that the client will negotiate with the server and take the highest protocol that server provides, so have forcefully change the protocol to the server to
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
but what happens to client that is framework 4? i tried to change the protocol on the client too but nothing change.
After some search i found the solution..
check
TLS 1.2 not negotiated in .NET 4.7 without explicit ServicePointManager.SecurityProtocol call.
Do not disable ServicePointManagerSecurityProtocols
As the say
'Setting Switch.System.ServiceModel.DisableUsingServicePointManagerSecurityProtocols to true limits Windows Communication Framework's (WCF) Transport Layer Security (TLS) connections to using TLS 1.0'
'If your application targets .NET Framework v4.6.2 or earlier and runs on .NET Framework v4.7 or later, set the switch's value to false.'
Just added
<AppContextSwitchOverrides value="Switch.System.ServiceModel.DisableUsingServicePointManagerSecurityProtocols=false" /> to app.config and works like before !

Configure Apache HttpClient 3.1 to use both SSL and TLS

I looked at the Apache HttpClient 3.1 documentation at http://hc.apache.org/httpclient-3.x/sslguide.html, and know that it comes out of box with HTTP over SSL. I'm trying to configure the client so that it uses TLS for servers that no longer support SSL but still maintain compatibility with ones that use SSL. Has anyone done this? Is it even possible?
If it helps, a solution to configure the client to use TLS is presented here: How to force Commons HTTPClient 3.1 to use TLS 1.2 only for HTTPS?
I am not able to upgrade to a more recent version of HttpClient at this time.

Migrate SOAP/REST client from TLS 1.0 to TLS 1.2

faced with next problem:
I have .net web application running under .NET Framework 4.5.2. Applicating communicates to SalesForce using:
SOAP API
REST API (https://github.com/developerforce/Force.com-Toolkit-for-NET/).
SalesForce announced disabling the TLS 1.0 encryption protocol on March 4, 2017. Do I need to do some adjustments in order to migrate to TLS 1.2?
The default System.Net.ServicePointManager.SecurityProtocol in .NET 4.5 is SecurityProtocolType.Tls|SecurityProtocolType.Ssl3, and .NET 4.5 supports up to TLS 1.2
Do I need to update System.Net.ServicePointManager.SecurityProtocol? If so, can it have an impact on communication with other api's?
I will be grateful for any help.
We had some issues in the log alerting us that we were logging on salesforce api using an old protocol not so long ago, after searching a bit i initialise the security protocol with
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
This will force all connection to use tls 1.2 within your program tho.
Sometime it seemed some call were trying to use tls1.0 with the default config... However to be sure you don't need to change just download your API log history and check if you have any connection attempt below tls1.2 and if its the case force the upgrade to tls1.2
You can also add the following registry keys to force TLS 1.2 in .NET 4.5+. They will only be overwritten if the System.Net.ServicePointManager.SecurityProtocol is specifically defined within the application.
Set/create the "SchUseStrongCrypto" DWORD value in the following two registry keys to 1: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\v4.0.30319 and
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft.NETFramework\v4.0.30319

How do I secure a WCF Service, hosted in IIS, using BasicHttp binding, and NO SSL Cert?

Is it possible to configure a WCF service that:
is hosted by IIS
uses the basicHttpBinding binding
does not need an SSL cert
supports sessions (ServiceContract(SessionMode:=ServiceModel.SessionMode.Required))
I know the easiest thing to do would be to buy an SSL cert, but for reasons beyond my control I am being required to match the 4 constraints above.
thanks,
Tom
Tell your boss that basicHttpBinding supports real security only when using with SSL certificate (otherwise all data are passed as a plain text) and it doesn't support WCF sessions out of the box. WCF session is dependent on either:
Transport session (only netTcp or netNamedPipe bindings)
Reliable session (only netTcp, wsHttp or custom bindings)
Security session (only wsHttp or custom bindings and it requires either windows authentication or SSL certificate)
Sessions can be probably added by building your own service behavior and replacing IInstaceContextProvider and perhaps also IInstanceProvider.

How does WCF + SSL working with load balancing?

If SSL is handled by a load balancer, do I still need to configure it in the WCF serviceCertificate node? My scenario is to use message level security. If someone can explain how load balancing with wcf and ssl works, that would be very nice.
WCF requires security tokens to be passed over a secure transport if the message itself is not signed/encrypted. Since traffic is HTTP between your Big-IP and your individual web servers, you need a way to have security tokens that you know are secured between the client and the Big-IP up front still be passed to your server farm. There's a couple ways to do that depending on what version of WCF you're using:
If you're using WCF 4.0 you can just create a custom binding and set the AllowInsecureTransport property on the built in SecurityBindingElement to signify that you don't care that the transport isn't secure.
If you're using WCF 3.5 you have to "lie" about security with a custom TransportSecurityBindingElement on the server side. You can read my old post about this here.
FWIW, they created a hotfix release for 3.5 SP1 that adds the AllowInsecureTransport to that version, but I don't know if your company will allow you to install custom hotfixes.
If you want to use message security then each message is encrypted and signed separately - there is no secure connection and load balancer behaves as with any other HTTP transport. Loadbalancer doesn't know about security and doesn't need certificate.
There are two gotchas:
All load balanced application servers hosting your WCF service must use the same certificate
You must ensure that your WCF binding doesn't use sessions (reliable, security) otherwise you will need load balancing algorithm with sticky sessions (all request for single session always routed to the same server)
It doesn't. Don't bother with this. You will be in a world of hurt. Just install the certs on each machine. We've recently been through this fiasco. WCF is not worth the effort it thinks it needs SSL but sees that it doesn't have it. Take a look at openrasta or something else if you want to do all your SSL on the loadbalancer. #microsoftfail