Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ?sslmode connection string param #2345

Merged
merged 3 commits into from
Oct 4, 2020

Conversation

benjie
Copy link
Contributor

@benjie benjie commented Sep 10, 2020

Fixes #1949

If you're using connection strings, you can't use the PGSSLMODE=no-verify envvar because that's only used when config.ssl is not set. I use ?ssl=true&sslmode=no-verify&sslrootcert=/app/data/amazon-rds-ca-cert.pem which does set config.ssl, so we need to also support parsing sslmode from the connection string. I've copied the logic (roughly) from:

var readSSLConfigFromEnvironment = function () {
switch (process.env.PGSSLMODE) {
case 'disable':
return false
case 'prefer':
case 'require':
case 'verify-ca':
case 'verify-full':
return true
case 'no-verify':
return { rejectUnauthorized: false }
}

I didn't see a CONTRIBUTING file, so I've taken a guess at the steps to make a good PR:

  • Added fix
  • Noted the GitHub issue it closes
  • Added test cases / 100% code coverage
  • Matched surrounding code style / passed linting
  • Sponsor @brianc 💖

@ianwalter
Copy link

Sponsored @brianc and @benjie. Thanks!

@brianc
Copy link
Owner

brianc commented Oct 4, 2020

Sorry for being so late on this. Went on a much needed vacation at the start of Sept & came back to a pretty disruptive life event. I just got out of the woods on that on Friday...finally. 🕺

This PR is perfect. I'm going to merge it & release a new minor version right now. ❤️

Also, really appreciate the sponsoring! ❇️

@gabooh
Copy link

gabooh commented Dec 22, 2023

Where is this documented ?
Should it be added here : https://node-postgres.com/features/ssl ?

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.

Postgres sslmode parameter support
4 participants