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

Enable SSL #532

Closed
Sneppers opened this issue Mar 10, 2014 · 9 comments
Closed

Enable SSL #532

Sneppers opened this issue Mar 10, 2014 · 9 comments

Comments

@Sneppers
Copy link

My host provider requires SSL (Heroku) to connect from remote locations.
Any idea on how to enable SSL in the connection string?

postgres://user:pass@host:port/database;

Been looking for it everywhere but it does not seem to be a very popular topic.
By the way, am using the connection-pooled method:

pg.connect(connString, function(err, client, done) {
/// Should work.
});

Please, let me know.

@brianc
Copy link
Owner

brianc commented Mar 10, 2014

Hey @Sneppers -

I use heroku a lot too. To enable ssl append '?ssl=require' to the query string of the connection string url, set an environment variable to PGSSLMODE=require or set it as your default pg settings in require('pg').defaults.ssl = true

@brianc brianc closed this as completed Mar 10, 2014
@Sneppers
Copy link
Author

Thank for the reply.
I just tried both:

postgres://user:pass@host:port/database?ssl=require;
and
require('pg').defaults.ssl = true

For both cases I still get the same connection refused error.
Any more ideas?

@brianc
Copy link
Owner

brianc commented Mar 10, 2014

Hmmm...that's strange. Try setting require('pg').defaults.ssl = 'require'

Also, this is how I usually do it: https://github.com/brianc/node-postgres/blob/master/test/integration/client/heroku-ssl-tests.js

@Sneppers
Copy link
Author

Finally, thank you.
The require('pg').defaults.ssl = 'require' did also not do it.
Simply putting the ssl property in the config object did the trick.

I am pretty sure I had tried that before... Anyway, works now.

@lepinsk
Copy link

lepinsk commented Jun 18, 2014

@brianc – my guess is that you're seeing people having issues with this because heroku's docs instruct hard-coding "pg": "0.6.15", (I suffered through the same problems above, for the same reason)

@brianc
Copy link
Owner

brianc commented Jun 18, 2014

barf - those docs are extreeeemly out of date! I've let them know before, & I'll contact them again.

@brianc
Copy link
Owner

brianc commented Jun 18, 2014

I talked to the heroku team & they updated the docs. @lepinsk thanks for pointing that out. :)

@lepinsk
Copy link

lepinsk commented Jun 18, 2014

Glad to be of assistance @brianc; it's the least I could do. :-)

@hunterloftis
Copy link

@brianc @lepinsk, I've updated the docs so users following them will always start with the latest version of pg. That should help folks avoid resolved issues in the future.

I've also added a note about the ssl requirements:

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

No branches or pull requests

4 participants