Skip to content

Commit f9ba412

Browse files
authored
Secure MSSQL transport defaults (#6766)
1 parent 4a57af2 commit f9ba412

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@effect/sql-mssql": patch
3+
---
4+
5+
**Breaking:** Secure Microsoft SQL Server connections by default by enabling encryption and validating server certificates.
6+
7+
Users connecting to SQL Server instances without TLS must now explicitly set `encrypt: false`. Users connecting with untrusted or self-signed certificates must explicitly set `trustServer: true`.

packages/sql/mssql/src/MssqlClient.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,13 @@ export interface MssqlClientConfig {
206206
readonly domain?: string | undefined
207207
readonly server: string
208208
readonly instanceName?: string | undefined
209+
/**
210+
* Whether to encrypt traffic between the client and server. Defaults to `true`. Setting this to `false` disables transport encryption and transmits credentials in cleartext.
211+
*/
209212
readonly encrypt?: boolean | undefined
213+
/**
214+
* Whether to trust the server certificate without validating it. Defaults to `false`. Setting this to `true` disables TLS certificate validation.
215+
*/
210216
readonly trustServer?: boolean | undefined
211217
readonly port?: number | undefined
212218
readonly authType?: string | undefined
@@ -284,15 +290,15 @@ export const make = (
284290
options: {
285291
port: options.port,
286292
database: options.database,
287-
trustServerCertificate: options.trustServer ?? true,
293+
trustServerCertificate: options.trustServer ?? false,
288294
multiSubnetFailover: options.multiSubnetFailover,
289295
connectTimeout: options.connectTimeout
290296
? Duration.toMillis(Duration.fromInputUnsafe(options.connectTimeout))
291297
: undefined,
292298
rowCollectionOnRequestCompletion: true,
293299
useColumnNames: false,
294300
instanceName: options.instanceName,
295-
encrypt: options.encrypt ?? false,
301+
encrypt: options.encrypt ?? true,
296302
cancelTimeout: options.cancelTimeout
297303
? Duration.toMillis(Duration.fromInputUnsafe(options.cancelTimeout))
298304
: undefined,

0 commit comments

Comments
 (0)