Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue creating a connection to SQL server 2014 with ODBC data source and TLS activated

I am trying to create / modify a system data source for my application which needs to connect to our Microsoft SQL Express 2014 database through an ODBC data source. The connection used to work before we enabled the SSL encryption flow but, now that we have an encrypted link, the connection does not work anymore.

Here are some details:

  • We run Microsoft SQL Server express 2014 SP1 with the latest cumulative update (CU #3) (which was necessary so that we could deactivate SSL 3.0 and TLS 1.0 and run only with TLS 1.1 and TLS 1.2)
  • The database instance is a named instance, configured to run with a TCP/IP connection and a fixed port.
  • We enabled the "Force Encryption" option and configured the certificate through the "Sql Server Configuration Manager"
  • We can successfully establish a connection to the database either using Management Studio or the SQL command line utility
  • We disabled all usage of SSL/TLS prior to version TLS 1.1 done through Microsoft Schannel. This required us to update SQL Express 2014 SP1 to the latest cumulative update (CU #3)
  • The ODBC data source we try to configure (through ODBC data source Administrator) is a "System DSN" and uses the "SQL server" driver and target the exact same server name as the one working in management studio (and whose server name corresponds to the machine FQDN which is reflected in the certificate CN value)
  • The Version indicated for the SQL Server ODBC driver is "Microsoft SQL Server ODBC Driver Version 06.03.9600"
  • I am testing the connection directly through the ODBC data source Administrator tool.
  • The first test I runs are run on the exact same machine as the one hosting the database server.

We get two consecutive error message in the Microsoft SQL Server Login:

Connection failed:
SQLState : '01000'
SQL Server Error: 771
[Microsoft][ODBC SQL Server Driver][TCP/IP  Sockets]ConnectionOpen(SECDoClientHandshake()).
Connection failed:
SQLState : '08001'
SQL Server Error: 18
[Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]SSL Security error.

I went through all the literature I could find but cannot find a solution.

EDIT 27/01/2016 16:30

Following erg suggestion, I tried to use the last MS SQL Server Native Client version (11.00.2100 on my system), but it still does not resolve the issue. I experience another issue though (whether or not I force the strong encryption on the client side results in the same error):

Running connectivity tests...

Attempting connection
[Microsoft][SQL Server Native Client 11.0]TCP Provider: An existing connection was forcibly closed by the remote host.

[Microsoft][SQL Server Native Client 11.0]Client unable to establish connection

TESTS FAILED!
like image 316
user2457451 Avatar asked Jan 27 '16 11:01

user2457451


People also ask

How can I tell if TLS 1.2 is enabled on SQL Server 2014?

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.

How do I fix ODBC connection failed in SQL Server?

Resolving The Problem. When you create the ODBC connection to SQL server, select the option of With SQL Server authentication using a login ID and password entered by the user. Also, confirm that in Microsoft Access, the Machine Data Source and System Data Source has been used to create the ODBC connection.

How do you check if TLS 1.2 is enabled?

In the Windows menu search box, type Internet options. Under Best match, click Internet Options. In the Internet Properties window, on the Advanced tab, scroll down to the Security section. Check the User TLS 1.2 checkbox.


1 Answers

So, I finally got it working after struggling a little bit more.

First of all, it appears that there is another CU available (CU4) for SQL Server Express 2014 SP1.

I did download it and install it, but it did not resolve my problem: as soon as I deactivated TLS 1.0 and below version ODBC did not work.

Strangely, though the CU3 and installation of .NET 4.6 allowed me to successfully log in in Management Studio, when I tried to execute the xp_readerrorlog query, it actually failed.

What I did to solve my issue was to follow malthus's answer on another related stack overflow question https://dba.stackexchange.com/questions/93127/sql-server-service-won-t-start-after-disabling-tls-1-0-and-ssl-3-0 (3rd answer from the top).

I therefore activated the local security policy on my computer and managed to get the links to my SQL db working.

Now, I got IIS working along my own service and client working.

BTW, if somebody needs a more user friendly way of activating SSL/TLS version(s) and cryptographic algorithms on Windows, I stumbled uppon a nice GUI application which does not required to use regedit for it:

https://www.nartac.com/Products/IISCrypto. It's free and I am not a a Nartac Software employee, manager or shareholder.

I hope this will help!

EDIT Feb 25, 2016

It looks like the latest cumulative update (CU5 available at https://support.microsoft.com/en-us/kb/3130926) removes the need to activate the FIPS option for the System Cryptography.

I discovered this since I had to deactivate FIPS to enable another required functionnality while still relying on a TLS 1.2 connection. Indeed, it appears that activating the FIPS option for the System Cryptography prevents .NET Framework to successfuly make use of some system algorithms (such as SHA256Managed).

In addition, according to some discussions seen around the web (i.e. http://blogs.technet.com/b/secguide/archive/2014/04/07/why-we-re-not-recommending-fips-mode-anymore.aspx) it is not recommended to activate FIPS (except to strictly comply with some governmental recommendations) since it breaks applications relying on non-FIPS validated implementations of cryptographic algorithms, which, however are provided in Microsoft system libraries.

like image 122
user2457451 Avatar answered Sep 30 '22 20:09

user2457451