Skip to content

Commit

Permalink
changes to tls-mode from default to prefer and update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
tanvipise committed Sep 17, 2024
1 parent 12a737a commit 15e641c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/vertica-nodejs/lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Client extends EventEmitter {
this.processID = null
this.secretKey = null
this.tls_config = this.connectionParameters.tls_config
this.tls_mode = this.connectionParameters.tls_mode || 'disable'
this.tls_mode = this.connectionParameters.tls_mode || 'prefer'
this.tls_trusted_certs = this.connectionParameters.tls_trusted_certs
this._connectionTimeoutMillis = c.connectionTimeoutMillis || 0
this.workload = this.connectionParameters.workload
Expand Down Expand Up @@ -197,7 +197,7 @@ class Client extends EventEmitter {
// once connection is established send startup message
con.on('connect', function () {
// SSLRequest Message
if (self.tls_mode !== 'disable' || self.tls_config !== undefined) {
if (self.tls_mode !== 'prefer' || self.tls_config !== undefined) {
con.requestSsl()
} else {
con.startup(self.getStartupConf())
Expand Down
4 changes: 2 additions & 2 deletions packages/vertica-nodejs/lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Connection extends EventEmitter {
this.tls_config = config.tls_config

if (this.tls_config === undefined) {
this.tls_mode = config.tls_mode || 'disable'
this.tls_mode = config.tls_mode || 'prefer'
//this.tls_client_key = config.tls_client_key
//this.tls_client_cert = config.tls_client_cert
this.tls_trusted_certs = config.tls_trusted_certs
Expand Down Expand Up @@ -90,7 +90,7 @@ class Connection extends EventEmitter {


// only try to connect with tls if we are set up to handle it
if (self.tls_config === undefined && self.tls_mode === 'disable') {
if (self.tls_config === undefined && self.tls_mode === 'prefer') {
return this.attachListeners(this.stream)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/vertica-nodejs/lib/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = {
// from the pool and destroyed
idleTimeoutMillis: 30000,
client_encoding: '',
tls_mode: 'disable',
tls_mode: 'prefer',
tls_key_file: undefined,
tls_cert_file: undefined,
options: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test('client settings', function () {
assert.equal(client.user, pguser)
assert.equal(client.database, pgdatabase)
assert.equal(client.port, pgport)
assert.equal(client.tls_mode, 'disable')
assert.equal(client.tls_mode, 'prefer')
})

test('custom', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ suite.test('ConnectionParameters initializing from config and config.connectionS
tls_mode: 'disable',
})

assert.equal(subject1.tls_mode, 'disable')
assert.equal(subject1.tls_mode, 'prefer')
assert.equal(subject2.tls_mode, 'require')
assert.equal(subject3.tls_mode, 'require')
assert.equal(subject4.tls_mode, 'require')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ suite.test('connection string parsing - tls_mode', function () {

string = 'vertica://brian:pw@boom:381/lala'
subject = new ConnectionParameters(string)
assert.equal(subject.tls_mode, 'disable')
assert.equal(subject.tls_mode, 'prefer')

string = 'vertica://brian:pw@boom:381/lala?tls_mode=verify-ca'
subject = new ConnectionParameters(string)
Expand All @@ -93,7 +93,7 @@ suite.test('connection string parsing - tls_mode', function () {
suite.test('tls mode is disable by default', function () {
clearEnv()
var subject = new ConnectionParameters()
assert.equal(subject.tls_mode, 'disable')
assert.equal(subject.tls_mode, 'prefer')
})

// restore process.env
Expand Down

0 comments on commit 15e641c

Please sign in to comment.