If you’re working with SQL Server and suddenly encounter a certificate trust error while connecting through Visual Studio, you’re not alone. Microsoft has recently updated the security handling in SQL Server, which may cause issues—especially when you’re using newer versions of drivers or default connection strings.
Table of Contents
Toggle
Let’s walk through what this error means and how to resolve it.
⚠️ Common Error Message:
“A connection was successfully established with the server, but then an error occurred during the pre-login handshake. The certificate chain was issued by an authority that is not trusted.”
✅ Quick Fix: Enable Trust Server Certificate
In most cases, the fastest solution is to set TrustServerCertificate=True
in your connection string.
You can do this from:
- Advanced settings when configuring your data source in Visual Studio
- Or directly inside your
.rdl
file or config file
🔍 Example:
Server=your_server_name;Database=your_db_name;
Integrated Security=True;TrustServerCertificate=True;
This setting tells SQL Server to skip verifying the SSL certificate’s trust chain—useful when working in development or local environments.
🛠 Other Solutions to Try
1️⃣ Use a Supported SQL Driver
Ensure you’re using the latest Microsoft OLE DB Driver for SQL Server (version 18.x or above). Older drivers may not fully support encryption protocols.
🔗 Download Microsoft OLE DB Driver
2️⃣ Modify the Encryption Setting
If your connection string is forcing encryption, try relaxing the encryption setting.
🔄 If your string has:
Encrypt=Yes
✅ Change it to:
Encrypt=Optional
📌 If Encrypt
is not present at all, simply add:
Encrypt=Optional
This allows the connection even if SQL Server doesn’t provide a trusted certificate.
3️⃣ Restart Visual Studio and SQL Server
Sometimes the issue persists due to old cached connections.
Try:
- Restarting Visual Studio
- Restarting SQL Server (LocalDB or full)
Then reconnect with the updated settings.
🧾 Summary Table
Problem | Solution |
---|---|
Certificate trust error | Set TrustServerCertificate=True |
Driver compatibility issues | Install OLE DB Driver 18+ |
Encryption errors | Set Encrypt=Optional in connection |
Still not working? | Restart Visual Studio and SQL Server |
💡 Final Tip
As SQL Server continues to improve its security model, these certificate validation checks will become stricter. It’s a good idea to:
- Keep drivers and tools updated
- Use trusted certificates in production
- Relax certificate checks only for local/dev use
Need help with troubleshooting more SQL Server or SSRS issues/Report ? Contact Me