Repository navigation
feat: accept Encrypt=strict in connection strings, and read Encrypt=optional as false - #1971
Merged
Merged
Conversation
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>
|
🎉 This PR is included in version 12.8.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does:
A connection string can now turn on TDS 8.0 strict encryption with
Encrypt=strict. tedious already acceptsencrypt: 'strict', but the parser readEncryptas a boolean, soEncrypt=strictgaveencrypt: true.The PR has two commits:
Encryptas 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 (as in fix: treat an empty Encrypt value in a connection string as not set #1960 and fix: treat empty boolean and number connection string values as not set #1961).Encrypt=Yeswhenoptions.encryptwas'strict'. That gave weaker encryption than asked for, with no error. It now writesEncrypt=Strict. ODBC Driver 18 and later accept this value. ODBC Driver 17 (the default on Linux and macOS) and SQL Server Native Client 11.0 do not, so the README says to setdriver.mandatoryandoptionalas synonyms oftrueandfalseforEncrypt. The parser gavetrueforoptional, because the library's boolean rule givestruefor every value exceptfalse,noand0.optionalnow givesfalse, andmandatorystill givestrue.Warning
With tedious,
encrypt: falsefails withEENCRYPTif the server requires encryption. Microsoft's drivers encrypt the connection in that case. So a connection string withEncrypt=optionalthat connects today to a server that requires encryption will fail after this change, the same wayEncrypt=falsefails today. The README now says this.References for the
Encryptvalues: TDS 8.0, SqlClient connection string keywords and ODBC connection string keywords.Tests:
strict,Strict,STRICT,{strict},mandatory,optional,Optional,1,0andFALSE, and for the tedious config.Encryptvalues. Only thestrictandoptionalvalues changed.Related issues:
None that I found.
Pre/Post merge checklist:
🤖 Generated with Claude Code