Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pre-login handshake woes with connecting directly to SQL Azure

We are currently experiencing a rather troublesome problem in our development environment with the following message...

A connection was successfully established with the server, 
but then an error occurred during the pre-login handshake. 
(provider: SSL Provider, error: 0 - The certificate's CN 
name does not match the passed value.)

...the commonly accepted wisdom to resolving this problem is to set the TrustServerCertificate portion of the connection to True. However, this does not work reliably or consistently.

This particular error occurs in a number of instances, for instance testing our WCF Service in our Azure Emulator talking to live / hosted SQL Azure Instance or even using SQL Management Studio. The only common denominator we've found is that this occurs only when we connect directly to SQL Azure as opposed to when its hosted and Azure is talking directly to SQL Azure (which does work).

I've tried a number of tactics to resolve the problem (such as the one detailed here), i.e. believing it was connection related and removing pooling and other modifications to the connection string. But alas, none are conclusive and more irritating is that the error is intermittent and will prevent access for a short period of time before magically resolving itself.

Other factors that I've eliminated.

  • We're using the Transcient Application Block to attempt to recover from these errors, but no.
  • Our office has no proxy server with our connection to the Azure hosted services.

Has anyone else experienced this problem or has any suggestions?

like image 516
SeanCocteau Avatar asked Sep 07 '12 09:09

SeanCocteau


People also ask

What is the only prerequisite for connecting to a database in Azure SQL Database?

Prerequisites. To complete this quickstart, you need Azure Data Studio, and an Azure SQL Database server. If you don't have an Azure SQL server, complete one of the following Azure SQL Database quickstarts.

Can't connect to Azure SQL managed instance?

If you are unable to connect to SQL Managed Instance from an Azure virtual machine within the same virtual network but a different subnet, check if you have a Network Security Group set on VM subnet that might be blocking access.


2 Answers

You need to scan for Non-IFS Winsock BSPs or LSPs which not compatible with the FILE_SKIP_COMPLETION_PORT_ON_SUCCESS flag ,problem results primarily from non-IFS LSPs Being installed.

Just run "netsh WinSock Show Catalog" from command prompt , and check any "service flag" which doesn't look in the format of 0x20xxx

In my case I found that "Speed Accelerator" with service flag 0x66,removing this software solve my Problem .

More information can be found here : http://support.microsoft.com/kb/2568167

like image 74
Feras Avatar answered Oct 17 '22 01:10

Feras


What does your connection string look like? Not sure if you've tried this yet but I remember having a problem similar when using a remote SQL connection to SQL Azure and found that I had to set:

Trusted_Connection=False;Encrypt=True

and remove any Connect Timeout from the string entirely.

like image 1
Scott Prokopetz Avatar answered Oct 17 '22 00:10

Scott Prokopetz