I recently started working on a new project based on .NET Core Framework 7. In this project, I'm using Entity Framework Core 7. However, when I try to build and run my project, I encounter an exception: '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.)' After searching online, I found a solution, so I thought I'd share it.
- [Solved]-How To Connect MySQL In ASP.NET Core 2024
- ASP .Net Core CRUD operations without using Entity Framework Step By Step Guide
- Crud operation in Asp .Net Core using Razor Pages Step By Step
- Crud operation in Asp.Net Core Mvc using jquery datatable with entity framework core database first
So let me share my thoughts on that. It's not a bug in EF Core 7.0 or 8.0; instead, it's an improved security feature. If you visit the Microsoft website, it suggests three options you can use:
1. Install a valid certificate.
2. Add 'TrustServerCertificate=True' to the connection string.
3. Add 'Encrypt=False' to the connection string.
Previously, SqlClient connection strings used 'Encrypt=False' by default. This allowed connections on development machines where the local server did not have a valid certificate.
However, in the latest version, SqlClient connection strings use 'Encrypt=True' by default.
This means the server must be configured with a valid certificate. That's why we now need to set the 'Encrypt' property to 'false' in case we don't have a valid certificate.
The connection string will look like the following:
Data Source=DESKTOP-MFLCOI2;Initial Catalog=HollyMelodyDb;User ID=sa;Password=adk@1234;Encrypt=false;
Read Similar Articles
- [Chart JS]- How to Make Sharp Lines to Smooth Curved Lines?
- [Answer]-"invalid options object. dev server has been initialized using an options object that does not match the api schema. - options.allowedhosts[0] should be a non-empty string."
- Automatically Calling The Base Method In C#
- Update an Image with Upload Button For Each Row in Gridview-Asp .Net
- [Solved]-Uploading both data and files in FormData using Ajax MVC
- Watts To VA Conversion Calculator | Watts To VA Conversion Formula