0

I've been upgrading an application from .net6 to .net 7 and I cannot connect to the database.

below is the connection string

"ConnectionStrings": {
    "DefaultConnection": "Server=.\\MYINSTANCE;Database=MyDatabase;User Id=MyUser; Password=MyPassoword;MultipleActiveResultSets=True;"
  }

And the connection

var connectionString = _configuration.GetConnectionString("DefaultConnection");
var connection = new SqlConnection(connectionString);
connection.Open();

Which works great in dotnet 6, however once i update to 7 it stops giving me the following 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.

Does anyone have any ideas on this or why this is happing?

Thom A
  • 88,727
  • 11
  • 45
  • 75
3xGuy
  • 2,235
  • 2
  • 29
  • 51
  • 3
    [Encrypt defaults to true for SQL Server connections](https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-7.0/breaking-changes#encrypt-true) – Thom A Mar 25 '23 at 14:56
  • 1
    If I had to take a guess, I'd say it's because "The certificate chain was issued by an authority that is not trusted". When faced with such a message, you should look up how to verify the certificate used by SQL Server, and how to obtain a valid certificate. – mason Mar 25 '23 at 14:57

0 Answers0