node-redshift icon indicating copy to clipboard operation
node-redshift copied to clipboard

Re: Support for SSL, Keep alive as connection option

Open guruatmicrosoft opened this issue 8 years ago • 6 comments

Couldnt see a place to put this request, it may not be an issue but rather feature ask.

I need to pass following options to my connection - ?tcpKeepAlive=true&ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory

Most of the code and document reference option as {rawConnection: true}, is there a way i can include above?

Thanks

guruatmicrosoft avatar Feb 11 '17 19:02 guruatmicrosoft

@guruattimeinc Yeah that's something that not currently supported, there's no way to pass in those parameters. The underlying node module(https://github.com/brianc/node-postgres) I'm using handles the actual connection to the database and it looks for specific options which are specified here(https://github.com/brianc/node-pg-pool#create)

Just out of curiosity where are you trying to connect? Because that doesn't look like any redshift connection in javascript i've ever seen.

dmanjunath avatar Feb 12 '17 04:02 dmanjunath

This is redshift DB, we have turned SSL settings. Is there a way i can setup connection with JDBC connection string? At the moment i am passing these params as part of connection string in SQL workbench.

Thanks

guruatmicrosoft avatar Feb 13 '17 03:02 guruatmicrosoft

@guruattimeinc Oh I see, you're using JDBC with SQL workbench. There are {ssl: true, and keepAlive: true} properties you can pass into the configuration, but there's no way to to pass the sslfactory parameter. If you try connecting with just those two properties does it work?

dmanjunath avatar Feb 19 '17 02:02 dmanjunath

I am getting the same error and adding {ssl: true, and keepAlive: true} does not fix the problem for me.

SgtPooki avatar May 18 '18 22:05 SgtPooki

I got things working with this:

const Redshift = require('node-redshift');
const fs = require('fs');

const client = {
  user: 'me',
  database: 'minez',
  password: 'secret',
  port: '1234',
  host: 'nunya',
  ssl: true,
};
const options = {
  ssl: {
    isServer: false,
    rejectUnauthorized: true,
    requestCertifiate: true,
    cert: fs.readFileSync("./cert.crt").toString(),
  },
  rawConnection: true,
};

const redshiftClient = new Redshift(client, options);

SgtPooki avatar May 18 '18 22:05 SgtPooki

This is redshift DB, we have turned SSL settings. Is there a way i can setup connection with JDBC connection string? At the moment i am passing these params as part of connection string in SQL workbench.

Thanks

I am also connecting to redshift using a JDBC connection string on SQL Workbench/J , even we pass the ?ssl=true&sslfactory values in the JDBC connection string.

I was able to connect to this redshift and query it while using the following code

const Redshift = require('node-redshift')

/** Set ssl : true **/

const client = {
	user : USER_NAME,
        database : DB_NAME,
        password : PASSWORD,
        port : '5439',
        host: HOST_URI,
        ssl : true
}

const redshiftClient = new Redshift(client, {rawConnection : true})

The above code worked for me with ssl : true, without specifying this I was getting this error "no pg_hba.conf entry for host"

Hope this helps anyone

293nav avatar Dec 31 '20 07:12 293nav