Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A connection was successfully established with the server, but then an error occurred during the login process. #1394

Closed
andrew-vdb opened this issue Nov 19, 2021 · 4 comments

Comments

@andrew-vdb
Copy link

Describe the bug

Unable to open trusted connection

A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)'

image

To reproduce

await connection.OpenAsync();

Expected behavior

It should connect

Further technical details

Microsoft.Data.SqlClient version: 4.0
.NET target: .net 6
SQL Server version:
image

Operating system: Win 10

Workaround
Use System.Data.SqlClient, it works.... or use Microsoft.Data.SqlClient 3.0.1

@cheenamalhotra
Copy link
Member

@andrew-vdb
Copy link
Author

Add
Encrypt=false
to connection string will work too

@RubberChickenParadise
Copy link

To anyone finding this, in my case it was due to the self signed server certificate. see #1210 (comment):

Systems using SQL Server's self-generated certificate will fail after this change and the user will have to buy a certificate or create a self-signed certificate, or change their connection string. If the change was made for scenarios where the user could not modify the connection string to enable encryption, then they are left having to get new certificates.

The fixes are:

  1. disable encryption on the client connection string with Encrypt=false
  2. blindly trust the server certificate with TrustServerCertificate=True
  3. use an external certificate on the sql server that is signed by a certificate authority in the clients trusted certificate authorities.
    3b) if the sql server already has an externally signed certificate, trust the signing certificate authority on the client.

@MeteAnn
Copy link

MeteAnn commented Jun 26, 2024

Ekran görüntüsü 2024-06-26 123826

I was experiencing the same issue, and it was resolved after adding Encrypt=false;.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants