Skip to content

Commit 6d07cc3

Browse files
authored
Merge pull request #158 from mikelr/AddSNISupport
Send hostname as default SNI name
2 parents 2a186b5 + 02e2e91 commit 6d07cc3

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

lib/protocol/tcp.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@ exports.connect = function connect(options, cb) {
2424
if ('key' in options || 'cert' in options || 'ca' in options || 'pfx' in
2525
options || options.useTLS === true) {
2626
createSocket = exports.createSecureSocket;
27+
if (!('servername' in options)) {
28+
options.servername = options.host;
29+
}
2730
} else {
2831
createSocket = exports.createSocket;
2932
}
3033
var socket = createSocket(options, cb);
3134
socket.setNoDelay(true);
3235
return socket;
33-
};
36+
};

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
],
77
"name": "hdb",
88
"description": "SAP HANA Database Client for Node",
9-
"version": "0.17.2",
9+
"version": "0.18.0",
1010
"repository": {
1111
"type": "git",
1212
"url": "git://github.com/SAP/node-hdb.git"

test/lib.tcp.js

+19-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,28 @@ describe('Lib', function () {
3030
tcp.createSecureSocket = function tlsConnect(options, cb) {
3131
tcp.createSecureSocket = createSecureSocket;
3232
options.allowHalfOpen.should.equal(false);
33+
options.servername.should.equal(options.host);
3334
process.nextTick(cb);
3435
return socket;
3536
};
3637
tcp.connect({
37-
pfx: true
38+
pfx: true,
39+
host: 'localhost'
40+
}, done).should.equal(socket);
41+
});
42+
43+
it('should override default servername', function (done) {
44+
tcp.createSecureSocket = function tlsConnect(options, cb) {
45+
tcp.createSecureSocket = createSecureSocket;
46+
options.allowHalfOpen.should.equal(false);
47+
options.servername.should.equal('customSNI');
48+
process.nextTick(cb);
49+
return socket;
50+
};
51+
tcp.connect({
52+
pfx: true,
53+
host: 'localhost',
54+
servername: 'customSNI'
3855
}, done).should.equal(socket);
3956
});
4057

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

5168
});
52-
});
69+
});

0 commit comments

Comments
 (0)