Quantcast
Channel: CodeSection,代码区,网络安全 - CodeSec
Viewing all articles
Browse latest Browse all 12749

getting SSL error on GeddyJs using Heroku PG on dev environment

0
0

i am using GeddyJs with a heroku cedar app deployment. I am using Heroku Postgres services for the database.

I have configured the username/password/hostname/dbname in the config file on geddyjs but when i go to run node app.js it throws an error for no pg_hba.conf i know this related to SSL not being used while accessing the db remotely but i have no clue how to force SSL on the connection..

Here is the error log: error: no pg_hba.conf entry for host "70.199.196.17", user "12345", database "database1", SSL off at p.parseE (/Users/mikedevita/Web/Sites/gorelative.com/node/node_modules/pg/lib/connection.js:503:11) at p.parseMessage (/Users/mikedevita/Web/Sites/gorelative.com/node/node_modules/pg/lib/connection.js:363:17) at Socket.p.attachListeners (/Users/mikedevita/Web/Sites/gorelative.com/node/node_modules/pg/lib/connection.js:86:20) at Socket.EventEmitter.emit (events.js:96:17) at TCP.onread (net.js:397:14) [Tue, 05 Mar 2013 22:39:49 GMT] ERROR Worker 843 died. my config/development.js file: var config = { detailedErrors: true , debug: true , hostname: 'localhost' , port: 3000 , model: { defaultAdapter: 'postgres' } , db: { postgres: { port: 5432 , password: 'foobar' , database: 'database1' , host: 'ec2-107-21-126-45.compute-1.amazonaws.com' , user: '12345' } } , sessions: { store: 'memory' , key: 'sid' , expiry: 14 * 24 * 60 * 60 } }; module.exports = config;

Problem courtesy of: gorelative

Solution

You need to add ssl: true to your postgres config.

postgres: { port: 5432 , password: 'foobar' , database: 'database1' , host: 'ec2-107-21-126-45.compute-1.amazonaws.com' , user: '12345' , ssl: true }

Geddy simply passes this config object to the pg module. Check the pg.client wiki page for more info.

Solution courtesy of: Miguel Madero

Discussion

If you are trying to connect from outside heroku you need to connect with SSL. We only allow connections from outside heroku if they are encrypted with SSL

error: no pg_hba.conf entry for host "70.199.196.17", user "12345", database "database1", SSL off says that you can't connect with SSL off.

Also you may be sanitizing your database name with database1, but if you're not, I can guarantee you that your database name is not, in fact, database1.

Also you should NOT NOT NOT be hard-coding your credentials in a file. Read them out of your environment.

Discussion courtesy of: Will

This recipe can be found in it's original form on Stack Over Flow .


Viewing all articles
Browse latest Browse all 12749