You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Microsoft.Data.SqlClient 2.0.0 A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: HTTP Provider, error: 0 - ) #609
After a NuGet update of Microsoft.Data.SqlClient from 1.1.3 to 2.0.0 I am no longer able to connect to SQL Server 2017 14.0.3294.2 (latest update).
I get an error: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: HTTP Provider, error: 0 - )
Code:
using (var cnn = new SqlConnection(CreateConnectionString(server, port, LoginDatabaseName, Username, Password)))
{
var cmd = new SqlCommand("uspGetDatabasesByLogin", cnn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@LoginName", login));
try
{
cnn.Open();
}
catch (SqlException ex)
{
//it goes here
greska = ex;
return ret;
}
...
I am using Windows. When I downgrade to 1.1.3 it all Works fine, so it has to do with the Microsoft.Data.SqlClient 2.0.0.
Poslano iz programa Pošta<https://go.microsoft.com/fwlink/?LinkId=550986> za Windows 10
Pošiljatelj: Erik Ejlskov Jensen<mailto:notifications@github.com>
Poslano:17. lipnja 2020. 14:27
Primatelj: dotnet/SqlClient<mailto:SqlClient@noreply.github.com>
Kopija: hovek<mailto:hove1982@hotmail.com>; Author<mailto:author@noreply.github.com>
Predmet: Re: [dotnet/SqlClient] Microsoft.Data.SqlClient 2.0.0 A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: HTTP Provider, error: 0 - ) (#609)
What OS are you using?
Maybe this is relevant: #567 (comment)<#567 (comment)> ?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#609 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABNJTD3LAS7VOUX5IUPABPDRXCZDPANCNFSM4OAQDQNQ>.
Yes, I set it up to force euncription, years ago and I do not wat to force user machines to trust it, I want it simple and practical and I don't want to pay for expensive trusted certs so, I'll try setting that option in conn str.
lp,
Hrvoje Batrnek
Maybe exception descriptions should be more accurate,descriptive and maybe give you some pointers. 😉
Poslano iz programa Pošta<https://go.microsoft.com/fwlink/?LinkId=550986> za Windows 10
Pošiljatelj: Erik Ejlskov Jensen<mailto:notifications@github.com>
Poslano:17. lipnja 2020. 19:59
Primatelj: dotnet/SqlClient<mailto:SqlClient@noreply.github.com>
Kopija: hovek<mailto:hove1982@hotmail.com>; Mention<mailto:mention@noreply.github.com>
Predmet: Re: [dotnet/SqlClient] Microsoft.Data.SqlClient 2.0.0 A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: HTTP Provider, error: 0 - ) (#609)
Maybe it would be helpful to have all breaking changes listed in on place?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#609 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABNJTDYMOC5HJSZP7HBLK6TRXD76HANCNFSM4OAQDQNQ>.
SSL Handshake/Pre-Login errors can occur due to many reasons and if trust was established, we'd receive error code from SQL Server, which is provided in error message. If Error code is 0, that would mean we did not receive response from server as trust could not be established and we are not aware of the reasons in the scope of driver.
Could you confirm if the above options worked for you and we are good to close this issue?
I know that, I was thinking in general.
Poslano iz programa Pošta<https://go.microsoft.com/fwlink/?LinkId=550986> za Windows 10
Pošiljatelj: Cheena Malhotra<mailto:notifications@github.com>
Poslano:18. lipnja 2020. 1:41
Primatelj: dotnet/SqlClient<mailto:SqlClient@noreply.github.com>
Kopija: hovek<mailto:hove1982@hotmail.com>; Mention<mailto:mention@noreply.github.com>
Predmet: Re: [dotnet/SqlClient] Microsoft.Data.SqlClient 2.0.0 A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: HTTP Provider, error: 0 - ) (#609)
Hi @hovek<https://github.com/hovek>
SSL Handshake/Pre-Login errors can occur due to many reasons and if trust was established, we'd receive error code from SQL Server, which is provided in error message. If Error code is 0, that would mean we did not receive response from server as trust could not be established.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#609 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABNJTDZWZYAYBBAN62PTN7DRXFICJANCNFSM4OAQDQNQ>.
________________________________
From: Cheena Malhotra <notifications@github.com>
Sent: Friday, June 19, 2020 11:23:07 PM
To: dotnet/SqlClient <SqlClient@noreply.github.com>
Cc: hovek <hove1982@hotmail.com>; Mention <mention@noreply.github.com>
Subject: Re: [dotnet/SqlClient] Microsoft.Data.SqlClient 2.0.0 A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: HTTP Provider, error: 0 - ) (#609)
Could you confirm if the above options worked for you and we are good to close this issue?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#609 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABNJTDYSUN5CP46ZXRMMES3RXPJLXANCNFSM4OAQDQNQ>.
Trust Server Certificate = true; solved it too for us. Maybe add it to the release notes?
This breaking change is mentioned in release notes, please view them in 2.0.0.md. Since the solution to server certificate validation is respective to customer application requirements, it's in the applications hands which option they would like to choose.
However the solutions are not new when connecting with forced encryption on server, and are same as documented here: Microsoft Docs: Using Encryption without validation), it was an incorrect driver behavior to not validate server certificate which has been fixed in this release.
@ErikEJ I've updated to use Microsoft.Data.SqlClient and still got the issue for connecting to MS sql server 2008, the details are in the post, could you help to take a look
Activity
ErikEJ commentedon Jun 17, 2020
What OS are you using?
Maybe this is relevant: #567 (comment) ?
hovek commentedon Jun 17, 2020
cheenamalhotra commentedon Jun 17, 2020
Hi @hovek
Please verify if your SQL Server forces encryption:
If yes, the driver now will validate server certificate on client systems.
You can try below options:
Trust Server Certificate = trueon connection string.This change has been introduced with v2.0.0-preview2 as mentioned in release notes (breaking changes).
hovek commentedon Jun 17, 2020
ErikEJ commentedon Jun 17, 2020
Maybe it would be helpful to have all breaking changes listed in on place?
cheenamalhotra commentedon Jun 17, 2020
That's been worked upon and will be published on Microsoft Docs soon.
ErikEJ commentedon Jun 17, 2020
I did a PR in the meantime!
hovek commentedon Jun 17, 2020
cheenamalhotra commentedon Jun 17, 2020
Hi @hovek
SSL Handshake/Pre-Login errors can occur due to many reasons and if trust was established, we'd receive error code from SQL Server, which is provided in error message. If Error code is 0, that would mean we did not receive response from server as trust could not be established and we are not aware of the reasons in the scope of driver.
Could you confirm if the above options worked for you and we are good to close this issue?
hovek commentedon Jun 18, 2020
cheenamalhotra commentedon Jun 19, 2020
Could you confirm if the above options worked for you and we are good to close this issue?
hovek commentedon Jun 20, 2020
CumpsD commentedon Jun 22, 2020
I am having the same issue with
Microsoft.Data.SqlClient 2.0.0usingAspNetCore.HealthChecks.SqlServer.Our application is running in
mcr.microsoft.com/dotnet/core/runtime-deps:3.1.5and connects to a standard Azure Sql Server.It stopped working after upgrading SqClient.
Trust Server Certificate = true;solved it too for us. Maybe add it to the release notes?CumpsD commentedon Jun 22, 2020
@ErikEJ it was
Server=Xxxx.database.windows.net;Database=Xxxx;User=Xxx@xxx.database.windows.net;Password=Xxxx;By adding
Server=Xxxx.database.windows.net;Database=Xxxx;User=Xxx@xxx.database.windows.net;Password=Xxxx;Trust Server Certificate=true;it works.ErikEJ commentedon Jun 22, 2020
Thanks, missed your update to your original post
cheenamalhotra commentedon Jun 22, 2020
This breaking change is mentioned in release notes, please view them in 2.0.0.md. Since the solution to server certificate validation is respective to customer application requirements, it's in the applications hands which option they would like to choose.
However the solutions are not new when connecting with forced encryption on server, and are same as documented here: Microsoft Docs: Using Encryption without validation), it was an incorrect driver behavior to not validate server certificate which has been fixed in this release.
We will close the issue as resolved.
shaojun commentedon Mar 6, 2023
could you guys help to take look at this similar issue: microsoft/azuredatastudio#11249 (comment)
ErikEJ commentedon Mar 6, 2023
@shaojun That is not similar, this repo is not for the no longer supported System.Data.SqlClient but for Microsoft.Data.SqlClient
shaojun commentedon Mar 9, 2023
@ErikEJ I've updated to use
Microsoft.Data.SqlClientand still got the issue for connecting to MS sql server 2008, the details are in the post, could you help to take a look