certificate chain not trusted .NET Origin: Application & API OSI layer 6 · Presentation Last updated 2 Dec 2026

SqlException: A connection was successfully established with the server, but then an error occurred during the login process. (The certificate chain was issued by an authority that is not trusted)

The SQL Server certificate is not trusted by the client, and Microsoft.Data.SqlClient 4+ encrypts by default.

Exact message you may see The certificate chain was issued by an authority that is not trustedSqlException error occurred during the login process
Seen on: .NET SQL Server

Meaning

Since SqlClient 4.0 Encrypt=true is the default. A self-signed server certificate (typical in dev and Docker) fails validation.

Common causes

  • Self-signed SQL Server certificate
  • Encrypt defaulting to true after a package upgrade
  • Certificate CN does not match the host
  • CA missing on the client

⚡ Quick fix

  1. Add TrustServerCertificate=True in dev only
  2. Install a trusted certificate on the server
  3. Add the CA to the client trust store

Detailed fix by platform

Connection string

  1. Server=db;Database=app;User Id=sa;Password=...;Encrypt=True;TrustServerCertificate=True

How to diagnose

  1. Version — SqlClient version?
  2. Cert — Self-signed?
  3. Env — Dev or prod?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.