megastef / node-crate

Node.js base DB-Driver for CRATE (www.crate.io)
52 stars 18 forks source link

Add https support for the connections #3

Closed martinheidegger closed 10 years ago

martinheidegger commented 10 years ago

There are services to provide databases to apps (like mongohq for mongo). Those connections should be done better using https. With a https reverse proxy in front of crate that could be possible with crate as well. It might be cool if node-crate would support https connections

megastef commented 10 years ago

I agree.

Like

crate.connect( {https: true, nodes: ['host1:443', 'host2:443']} )
martinheidegger commented 10 years ago

The python connection string looks like that (if I am not mistaken):

host1:port1 host2:port2

To be compatible, I think it might be better to make https (and http) as optional part of the connection string.

crate.connect("host") // http, port 80
crate.connect("host:443") // http, port 443
crate.connect("https://host") // https, port 443
crate.connect("https://host:8443") // https, port 8443
crate.connect("http://host") // http, port 80
crate.connect("https://host https://host2") // https, port 443; fallback to https port 443 on domain host2 if the connection to the first one failed.
megastef commented 10 years ago

Could you test with an https proxy? Just checked in 1.0.3 with new connection management.

could you pls. do

npm install node-crate
// crate.connect ('localhost', 4200)
crate.connect ('https://proxy:4200')
// to use multiple nodes in round robin crate.connect ('http://host1:4200 http://host2:4200')
// to use https crate.connect ('https://host1:4200 https://host2:4200')
megastef commented 10 years ago

Maybe there is something to do for self-signed certificates ...

megastef commented 10 years ago

For self-signed certificates please set

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"