-
Notifications
You must be signed in to change notification settings - Fork 305
The certificate chain was issued by an authority that is not trusted. #3235
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
Comments
What are you connecting to? |
SQL Server 2022 |
Hi @qbqmbur, can you please provide the additional information requested in the bug report template? |
Error Message
Stack trace:
Code to reproduce:
Expected behaviorOpen a connection to the Further technical detailsMicrosoft.Data.SqlClient version: 6.0.1 Additional context
|
Thanks for the additional info @qbqmbur. Can you check if you have "Force strict encryption" enabled on your server? You can see it in Sql Server Configuration Manager under SQL Server Network Configuration > Right click > Properties. For example: |
Hi @qbqmbur Please note that with Microsoft.Data.SqlClient, "Encrypt" connection property is "True" or "Mandatory" by default, which was not the case with System.Data.SqlClient. So you will need to configure server certificates on client in order to connect successfully, or provide "Encrypt=false" on connection string in order to unblock yourself temporarily. To ensure optimum security, we recommend setting up encryption certificate as default security requirement. |
It looks like we are connecting to |
Can you confirm whether you're using managed networking? You can check for this AppContext switch: "Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows" |
I've checked with
I assume that this is now something I should check with a server admin or can it still be something in the package? |
Yeah, all of the information you've provided so far does indicate that the server certificate is being evaluated. Either the server settings are enforcing "strict" encryption (which causes Trust Server Certificate to be ignored), or the options in your connection string are being overridden somehow. Maybe you can debug into the |
According to error: "Certificate name mismatch. The provided 'DataSource' or 'HostNameInCertificate' does not match the name in the certificate." Can you try to use the same hostname as specified in the certificate? |
How can I debug into this? It's pretty deep in the call-chain. |
There's a few things I'd recommend for you to try:
|
We are using a .Net 8 console application. With this we want to create a database connection using
Microsoft.Data.SqlClient
package becauseSystem.Data.SqlClient
is marked as deprecated.For this we are using a connection string with the format
Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=<database>;Data Source=<server>;Encrypt=True;TrustServerCertificate=True;
.Executing the code we get this error:
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.)
When we change the used package to
System.Data.SqlClient
the application works without any other changes.The text was updated successfully, but these errors were encountered: