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

The certificate chain was issued by an authority that is not trusted. Upgrade from net-6 to Net-7 #1836

Closed
1 task done
Vikas8881 opened this issue Nov 12, 2022 · 10 comments
Closed
1 task done
Labels
By Design By design

Comments

@Vikas8881
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Today I update the project from core 6 to 7. and after this when i try to execute any API then I get this error

Microsoft.Data.SqlClient.SqlException (0x80131904): 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.)
---> System.ComponentModel.Win32Exception (0x80090325): The certificate chain was issued by an authority that is not trusted.

But in core 6 it's working fine.

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

7

Anything else?

No response

@davidfowl
Copy link
Member

Seems like a SQL issue? What database are you connecting to?

@davidfowl davidfowl transferred this issue from dotnet/aspnetcore Nov 13, 2022
@ErikEJ
Copy link
Contributor

ErikEJ commented Nov 13, 2022

Read the breaking changes for EF Core 7 - due to update to SqlClient 5.0.1

@roji roji transferred this issue from dotnet/efcore Nov 13, 2022
@lcheunglci
Copy link
Contributor

lcheunglci commented Nov 13, 2022

Thanks @ErikEJ ,

When upgrading from EF Core 6 to EF Core 7, the dependency of Microsoft.Data.SqlClient went from 2.1.4 to 5.0.1 and the Encrypt default value went from false to true i.e. mandatory, so you'll either need to set it to set it explicitly to Encrypt=false or TrustServerCertificate=true or HostNameInCertificate=<CN Subject of your certificate>.

https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-7.0/breaking-changes#encrypt-true

@lcheunglci lcheunglci added the By Design By design label Nov 13, 2022
@lcheunglci lcheunglci added this to Needs triage in SqlClient Triage Board via automation Nov 13, 2022
@Vikas8881
Copy link
Author

Seems like a SQL issue? What database are you connecting to?

I use MS SQL Server
SQL Server Management Studio 15.0.18424.0
SQL Server Management Objects (SMO) 16.100.47021.0+7eef34a564af48c5b0cf0d617a65fd77f06c3eb1
Microsoft Analysis Services Client Tools 15.0.19750.0
Microsoft Data Access Components (MDAC) 10.0.22621.819
Microsoft MSXML 3.0 6.0
Microsoft .NET Framework 4.0.30319.42000
Operating System 10.0.22621

@Vikas8881
Copy link
Author

Thank you Everyone's Issue was Resolved By adding TrustServerCertificate=True; in the Connection String in AppSettings
and its work.

SqlClient Triage Board automation moved this from Needs triage to Closed Nov 13, 2022
@Vikas8881 Vikas8881 changed the title The certificate chain was issued by an authority that is not trusted. The certificate chain was issued by an authority that is not trusted. Upgrade from net-6 to Net-7 Nov 13, 2022
@yogapratama12428
Copy link

it work for me, thanks @Vikas8881

@proalaayahia
Copy link

proalaayahia commented Oct 23, 2023

Thank you Everyone's Issue was Resolved By adding TrustServerCertificate=True; in the Connection String in AppSettings and its work.
@Vikas8881
Is there a safer way than this?

@roji
Copy link
Member

roji commented Oct 23, 2023

@proalaayahia and others, the secure (right) way to solve this is not to add Trust Server Certificate=true, but rather to ensure that your SQL Server has a valid certificate. This protects against security attacks between your application and the database.

@SrkPrasadChangala
Copy link

Thank you Everyone's Issue was Resolved By adding TrustServerCertificate=True; in the Connection String in AppSettings and its work.

It worked for me.

@saman-ar
Copy link

saman-ar commented Jan 9, 2024

Adding TrustServerCertificate=True to the connection string fixed this issue in entityframework 8.

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

No branches or pull requests

9 participants