dmanjunath / node-redshift

A simple collection of tools to help you get started with Amazon Redshift from node.js
69 stars 48 forks source link

Re: Support for SSL, Keep alive as connection option #9

Open guruatmicrosoft opened 7 years ago

guruatmicrosoft commented 7 years ago

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

dmanjunath commented 7 years ago

@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.

guruatmicrosoft commented 7 years ago

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

dmanjunath commented 7 years ago

@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?

SgtPooki commented 6 years ago

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

SgtPooki commented 6 years ago

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);
293nav commented 3 years ago

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