Skip to content

fix: keep the ssl options when DATABASE_URL carries sslmode - #311

Merged
Bccorb merged 1 commit into
mainfrom
fix/sequelize-keeps-ssl-options
Sep 13, 2026
Merged

Bccorb merged 1 commit into
mainfrom
fix/sequelize-keeps-ssl-options

Conversation

@Bccorb

@Bccorb Bccorb commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

What

resolveSslOptions turns DB_SSL, or an sslmode on DATABASE_URL, into dialectOptions.ssl. Sequelize then reads the same sslmode for itself and merges pg-connection-string's reading of it over dialectOptions (the postgres branch of the URL constructor). With pg-connection-string 2.14 that reading is ssl: {}, so for a URL carrying sslmode the options were discarded and the certificate verified whatever DB_SSL or DB_SSL_REJECT_UNAUTHORIZED said. Against Amazon RDS, whose CA is not in Node's trust store, that is a boot failure. It also meant DB_SSL=false could not turn TLS off for such a URL, although resolveSslOptions and 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 plus DB_SSL=require, and the URL built from those never carries sslmode. Migrations are unaffected either way: config.cjs gives sequelize-cli discrete fields.

withoutSslMode in database.cjs (typed in database.d.cts) takes sslmode out of the string getSequelize constructs with, once resolveSslOptions has read it. Three tests, and the existing DB_URI test 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) and npm run build pass.

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
Bccorb force-pushed the fix/sequelize-keeps-ssl-options branch from 71d70d2 to d7ab4ae Compare September 13, 2026 14:25
@Bccorb
Bccorb merged commit 528f627 into main Sep 13, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant