Skip to content

feat: accept Encrypt=strict in connection strings, and read Encrypt=optional as false - #1971

Merged
dhensby merged 2 commits into
tediousjs:masterfrom
dhensby:claude/modest-chaum-e5f8e7
Nov 20, 2026
Merged

dhensby merged 2 commits into
tediousjs:masterfrom
dhensby:claude/modest-chaum-e5f8e7

Conversation

@dhensby

@dhensby dhensby commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

What this does:

A connection string can now turn on TDS 8.0 strict encryption with Encrypt=strict. tedious already accepts encrypt: 'strict', but the parser read Encrypt as a boolean, so Encrypt=strict gave encrypt: true.

The PR has two commits:

  1. feat: accept Encrypt=strict in connection strings
  2. fix: read Encrypt=optional as false in connection strings
    • SqlClient 5 and ODBC Driver 18 accept mandatory and optional as synonyms of true and false for Encrypt. The parser gave true for optional, because the library's boolean rule gives true for every value except false, no and 0. optional now gives false, and mandatory still gives true.

Warning

With tedious, encrypt: false fails with EENCRYPT if the server requires encryption. Microsoft's drivers encrypt the connection in that case. So a connection string with Encrypt=optional that connects today to a server that requires encryption will fail after this change, the same way Encrypt=false fails today. The README now says this.

References for the Encrypt values: TDS 8.0, SqlClient connection string keywords and ODBC connection string keywords.

Tests:

  • Unit tests for strict, Strict, STRICT, {strict}, mandatory, optional, Optional, 1, 0 and FALSE, and for the tedious config.
  • Unit tests for the connection string that the msnodesqlv8 pool builds, with a stand-in for msnodesqlv8.
  • I compared the parser with the library for 29 Encrypt values. Only the strict and optional values changed.
  • I did not test strict encryption against a server.

Related issues:

None that I found.

Pre/Post merge checklist:

  • Update change log

🤖 Generated with Claude Code

dhensby and others added 2 commits November 19, 2026 14:57
The parser read `Encrypt` as a boolean, so `Encrypt=strict` gave
`encrypt: true`. tedious accepts `encrypt: 'strict'` for TDS 8.0 strict
encryption, but a connection string could not set it.

The parser now reads `Encrypt` as a string. `strict`, in any case,
gives `'strict'`. Other values keep the boolean meaning of
@tediousjs/connection-string, and an empty value is still not set.

The msnodesqlv8 driver wrote `Encrypt=Yes` when `options.encrypt` was
`'strict'`, which gave weaker encryption than asked for. It now writes
`Encrypt=Strict`. ODBC Driver 18 and later accept this value; older
drivers do not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SqlClient 5 and ODBC Driver 18 accept `mandatory` and `optional` as
synonyms of `true` and `false` for `Encrypt`. The parser used the
boolean rule of @tediousjs/connection-string, which gives `true` for
every value except `false`, `no` and `0`. So `Encrypt=optional` turned
encryption on.

`optional`, in any case, now gives `false`. `mandatory` still gives
`true`.

With the tedious driver, a connection with `encrypt: false` fails if
the server requires encryption. A connection string with
`Encrypt=optional` now has this behaviour too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dhensby
dhensby marked this pull request as ready for review November 20, 2026 09:05
@dhensby
dhensby merged commit 4783975 into tediousjs:master Nov 20, 2026
47 checks passed
@dhensby
dhensby deleted the claude/modest-chaum-e5f8e7 branch November 20, 2026 11:17
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 12.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant