efcore: EFCore.SqlServer 6.0.1 Untrusted certificate authority error
Why is ef core trying to use ssl encrypted connection to connect to database when switching from 6.0.0 to 6.0.1?
When we update EntityFrameworkCore.SqlServer from Version 6.0.0 to Version 6.0.1 we cannot connect to our database anymore because of an untrusted certificate authority error.
It also happens when we try Scaffolding.
ConnectionString:
Data Source=localhost;Initial Catalog=local-Sales;Persist Security Info=True;User ID=sa;Password=sa-local-2019;
StackTrace:
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 I add trustServerCertificate=true
to the connection string it works again:
Data Source=localhost;Initial Catalog=local-Sales;Persist Security Info=True;User ID=sa;Password=sa-local-2019;trustServerCertificate=true
Did you made this change on purpose?
I cannot find anything about this change in the documents.
EF Core version: 6.0.1 Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer) Target framework: (e.g. .NET 6.0) Operating system: Windows 10 IDE: Jetbrains Rider 2021.3.1
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 4
- Comments: 21 (6 by maintainers)
@ErikEJ adding
trustServerCertificate=true
does fix it.Is there an issue adding that in?
You need to have a look at this : https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-7.0/breaking-changes#high-impact-changes
SqlClient dependency down to 2.1 Published v6.2.8
Yes, EF Core 7 already uses version 5: https://github.com/dotnet/efcore/blob/main/src/EFCore.SqlServer/EFCore.SqlServer.csproj#L51
EFCore.Bulkextensions explicitly depends on SqlClient 4.0. It should not do that, that is why you are facing breaking changes.
I would ask the author to stop doing that, and just use the 2.1 version the EF Core SqlServer package depends on instead. @borisdj
Hi there!
Just faced this issue too - we could no longer make new migrations and/or connect to local DBs, as this error then appeared. I saw you asked earlier for a csproj file, here’s ours:
`<Project Sdk="Microsoft.NET.Sdk.Web">
</Project> `and
`<Project Sdk="Microsoft.NET.Sdk">
</Project>`
I believe that’s all of the relevant ones. Hope it helps, and thanks for the work on EF Core - SQL would have been a pain without 😃
I suspect its EFCore BulkExtensions here that refers o that, since the other packages are at 6.0.0 and not 6.0.1, as others pointed out was where the issue was introduced for them…
NB. Adding “trustServerCertificate=true” to our connection strings fixed our issues with not being able to connect to our DBs, when running our micro services locally 😃 Thanks for that tip!