certificate chain not trusted 🗃️ SQL

SQL Server: The certificate chain was issued by an authority that is not trusted.

The client requires an encrypted connection and doesn’t trust SQL Server’s (often self-signed) certificate.

Seen on: SQL

Meaning

Microsoft.Data.SqlClient 4.0+ and ODBC Driver 18 default to Encrypt=True. Servers with self-signed certificates fail validation.

Common causes

  • Encrypt=True by default with a self-signed server certificate
  • Certificate not issued for the server name

⚡ Quick fix

  1. Install a trusted certificate on SQL Server
  2. For development: TrustServerCertificate=True
  3. Or Encrypt=False on trusted networks

Detailed fix by platform

.NET

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

How to diagnose

  1. Driver — Version (encrypt default)?
  2. Certificate — Trusted CA?

🧠 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.