Skip to content

Commit

Permalink
Merge pull request #158 from mikelr/AddSNISupport
Browse files Browse the repository at this point in the history
Send hostname as default SNI name
  • Loading branch information
mikelr authored May 19, 2020
2 parents 2a186b5 + 02e2e91 commit 6d07cc3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/protocol/tcp.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ exports.connect = function connect(options, cb) {
if ('key' in options || 'cert' in options || 'ca' in options || 'pfx' in
options || options.useTLS === true) {
createSocket = exports.createSecureSocket;
if (!('servername' in options)) {
options.servername = options.host;
}
} else {
createSocket = exports.createSocket;
}
var socket = createSocket(options, cb);
socket.setNoDelay(true);
return socket;
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
],
"name": "hdb",
"description": "SAP HANA Database Client for Node",
"version": "0.17.2",
"version": "0.18.0",
"repository": {
"type": "git",
"url": "git://github.com/SAP/node-hdb.git"
Expand Down
21 changes: 19 additions & 2 deletions test/lib.tcp.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,28 @@ describe('Lib', function () {
tcp.createSecureSocket = function tlsConnect(options, cb) {
tcp.createSecureSocket = createSecureSocket;
options.allowHalfOpen.should.equal(false);
options.servername.should.equal(options.host);
process.nextTick(cb);
return socket;
};
tcp.connect({
pfx: true
pfx: true,
host: 'localhost'
}, done).should.equal(socket);
});

it('should override default servername', function (done) {
tcp.createSecureSocket = function tlsConnect(options, cb) {
tcp.createSecureSocket = createSecureSocket;
options.allowHalfOpen.should.equal(false);
options.servername.should.equal('customSNI');
process.nextTick(cb);
return socket;
};
tcp.connect({
pfx: true,
host: 'localhost',
servername: 'customSNI'
}, done).should.equal(socket);
});

Expand All @@ -49,4 +66,4 @@ describe('Lib', function () {
});

});
});
});

0 comments on commit 6d07cc3

Please sign in to comment.