Problem with SSL certificate in connection string

Hi All,

I am in the process of moving my application to a new server. In more detail we are moving from a on premises environment to Azure platform.

During the migration I still want to able connect to the old database server (MS SQL). Using Management Studio that is possible, so it must also be possible for my application.

But I am getting this error:


"SSL Provider: De certificaatketen is verleend door een niet-vertrouwde instantie."
In English that is: "SSL Provider: The certificate chain was issued by an untrusted authority."

When I click away that error the SQL login pops up. Clicking Cancel and wait a few seconds my application pops up and I can view may data. So somehow the connection string works but an untrusted certificate might be the problem.

The connection string MS SQL Management Studio uses is:
Data Source=******,***;Initial Catalog=HIMS;Persist Security Info=True;User ID=*******;Password=●●●●●●;Pooling=False;MultipleActiveResultSets=False;Encrypt=False;TrustServerCertificate=False;Application Name="SQL Server Management Studio";Command Timeout=0

The interesting part to me is TrustServerCertificate=False Probably that makes is possible for Management Studio to connect to the database without an error popping up.

Can I modify my connection string that it will ignore the certificate and makes a connection anyway?

Maybe this help
Azure SQL Database connection strings - ConnectionStrings.com

Specifically this
SQL Server Native Client 10.0 ODBC Driver Connection Strings - ConnectionStrings.com


Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;

Well, that is a quick response, thanks.

You are saying I must prepend {SQL Server Native Client 10.0} to the connection string.
That appears for MS SQL server 2008.

The database is running on Compatibility Level SQL Server 2012 (110). Will forcing to use a Native Client for 2008 work safely?

I made my connection string like:
SQL Server Native Client 10.0,"MySQLServer,1434",MyDataBase,MyUserName,MyPassword
and now it is complaining on Named Pipes :grinning_face:.

So that is one step forward. I have changed setting earlier so I can manage.

Your error window shows that the client is using ODBC Driver 18 for SQL.
And that your client does not trust the certificate on the server.

Easiest will probably tell the client to trust the server certificate.
Microsoft has been changing defaults for SQL drivers.

I guess you mean this "fix the server certificate or the client's trust store." That is what you link mentions somewhere. I have to ask that to our administrator tomorrow.

Back to the native client suggested above. That makes me wonder what client my application is using on the old server. How can I figure out what client my application is using on that server?

You don't need to fix the client's trust store, just how you're connecting.
In your first post, one element is

TrustServerCertificate=False

I added TrustServerCertificate=False to my connection string that is somewhat working. No error popup but my application takes around 10 seconds to start. It might be that my application is still on Clarion 11 that it isn't working very well.

As I don't have Capesoft's driver kit I will go for this route: use ODBCAdmin to create a DSN. Tomorrow I will ask the administrator to help me with that.

Thank you for thinking with me.

You are doing it backwards.

Trust server certificate needs to be TRUE.

The error says it isn't trusted, so you need to trust it.

Well that makes sense so I tried it. The result is te same: The application starts but it takes approx. 10 seconds.

Certainly the TrustServerCertificate does something. If I make my connection string like
"MySQLServer,1434",MyDataBase,MyUserName,MyPassword,TrustServerCertificate=False
or "MySQLServer,1434",MyDataBase,MyUserName,MyPassword,TrustServerCertificate=True it starts without the error popup, but after a while.

If I do "MySQLServer,1434",MyDataBase,MyUserName,MyPassword,TrustServerCertificate I get the same error immediate.

I don't know what you're doing.

But if you have, indeed, started specifying SQL Server Native Client 10.0, then the certificate trust stuff is irrelevant. Certificates and encryption were not included in those old (deprecated) clients.

I tried both Native Client 10.0 and more modern clients to solve this problem. With the native client I ran into the named pipes problem. With the SQL Server version 18 there is a problem with the certificate.

First thing I will do now is contact the administrator because the error says The certificate chain was issued by an untrusted authority. Let him set that things right first, then I will try again your suggestions. This whole discussion is making me more aware about the differences between the native clients and the ODBC drivers.

Koen, one thing worth checking with your administrator is SQL Server Configuration Manager on the old SQL Server.

Under SQL Server Network Configuration β†’ Protocols for [Instance], you can check whether TCP/IP is enabled, which port SQL Server is listening on, and the certificate and encryption settings.

If you're running SQL Server Express, TCP/IP is normally disabled by default on installation, so that's particularly worth checking.

The Certificate and Flags tabs under the protocol properties are also relevant to your certificate error.

Since you've encountered both Named Pipes and certificate errors, I'd suggest confirming the network configuration first, including whether SQL Server is actually listening on TCP port 1434 as specified in your connection string.

As Jane mentioned, ODBC Driver 18 enables encryption by default, which can expose certificate trust issues that didn't arise with older drivers.

I'd get the administrator to check those settings before experimenting with any more drivers.

Today I had I talk with the administrator and the clarified some things. He told that on the old server ODBC driver version 13 and the native driver version 11.0 were installed. But named pipes on the SQL server was not switched on so we concluded that we are using ODBC driver version 13.

His suggestion was to add Encrypt=Optional to the connection string.That worked but with the same result as adding TrustServerCertificate=True. The application starts but it takes over 10 seconds. Opening browses is slow.

So my conclusion is that I actually have two problems. The first one is solved by adding a certificate and/or encryption setting to connection string.
And second, it appears that the connection itself is very slow. I ask the administrator tomorrow.

Meanwhile I am grateful for the replies I got. It made me a bit wiser on ODBC drivers etc. what I paid not that much attention to in the past.

One more thing to mention left. I realised that all my attempts were when trying to run the application elevated. So I did the same tests non-elevated and the funny thing was that even the original connection string was working. But still dead slow in starting.

Once again thanks all.