Description
With Encrypt=False, a SQL Server client does not require encryption for the entire connection. The server’s force-encryption setting and the driver version also affect the actual protection.
Potential impact
Unencrypted queries and results can be read or altered. Skipping certificate validation can send credentials to an impersonating server.
Remediation
Require encryption on the client in production. Configure a certificate that the client trusts and that matches the server name used to connect.
Examples
Before
csharp
using var connection = new SqlConnection(
"Server=db;Database=App;Encrypt=False");
After
csharp
using var connection = new SqlConnection(
"Server=db;Database=App;Encrypt=True;TrustServerCertificate=False");
The second connection string sets Encrypt=True;TrustServerCertificate=False. Opening a connection with these settings requires encryption and a valid server certificate.