fix: keep the ssl options when DATABASE_URL carries sslmode - #311
Merged
Merged
Conversation
Sequelize reads the query of a connection string for itself and lets pg-connection-string's reading of sslmode replace the ssl options it was handed, so a DATABASE_URL with sslmode=require had the certificate verified whatever DB_SSL or DB_SSL_REJECT_UNAUTHORIZED said, and DB_SSL=false could not turn TLS off for it. The stacks pass the discrete DB_* variables, whose URL never carries the parameter, so nothing deployed is affected. Sequelize is now constructed with sslmode taken out of the URL, once resolveSslOptions has read it.
Bccorb
force-pushed
the
fix/sequelize-keeps-ssl-options
branch
from
September 13, 2026 14:25
71d70d2 to
d7ab4ae
Compare
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
resolveSslOptionsturnsDB_SSL, or ansslmodeonDATABASE_URL, intodialectOptions.ssl. Sequelize then reads the samesslmodefor itself and mergespg-connection-string's reading of it overdialectOptions(the postgres branch of the URL constructor). With pg-connection-string 2.14 that reading isssl: {}, so for a URL carryingsslmodethe options were discarded and the certificate verified whateverDB_SSLorDB_SSL_REJECT_UNAUTHORIZEDsaid. Against Amazon RDS, whose CA is not in Node's trust store, that is a boot failure. It also meantDB_SSL=falsecould not turn TLS off for such a URL, althoughresolveSslOptionsand its test say it does.Found in production on
roxtarget-api, which shares this construction (fells-code/roxtarget-api#3); the same change is in fells-code/seamless-templates#91, fells-code/grand-cross-api#26 and fells-code/seamless-idea-api#145.Nothing deployed is affected. Every stack hands the auth image the discrete
DB_*variables plusDB_SSL=require, and the URL built from those never carriessslmode. Migrations are unaffected either way:config.cjsgives sequelize-cli discrete fields.withoutSslModeindatabase.cjs(typed indatabase.d.cts) takessslmodeout of the stringgetSequelizeconstructs with, onceresolveSslOptionshas read it. Three tests, and the existingDB_URItest now asserts the stripped URL, which is the behaviour that changed. Patch changeset.Checks
npm run typecheck,npm run lint,npm run format:check,npm run test:run(1468 tests) andnpm run buildpass.