SqlException: certificate chain not trusted
Version 4 of
Microsoft. includes a breaking change which sets
Encrypt=True by default. If the client and server are not configured with a valid certificate, this can cause an exception at startup:
System.Data.SqlClient.SqlException HResult=0x80131904 Message=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.) Source=.Net SqlClient Data Provider
To fix this, the SQL Server installation must be updated with a valid certificate and the machine hosting the endpoint must be updated to trust this certificate.
It is not recommended to eliminate this warning by adding
TrustServerCertificate=Trueto the connection string. Both of these options leave the endpoint unsecure.