Skip to content

Commit b086179

Browse files
holgerkoserlpinca
authored andcommitted
[fix] Allow to disable sending the SNI extension (#1587)
1 parent e9e8ba5 commit b086179

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/websocket.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,11 @@ function netConnect(options) {
668668
*/
669669
function tlsConnect(options) {
670670
options.path = undefined;
671-
options.servername = options.servername || options.host;
671+
672+
if (!options.servername && options.servername !== '') {
673+
options.servername = options.host;
674+
}
675+
672676
return tls.connect(options);
673677
}
674678

test/websocket.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const assert = require('assert');
66
const crypto = require('crypto');
77
const https = require('https');
88
const http = require('http');
9+
const tls = require('tls');
910
const fs = require('fs');
1011
const { URL } = require('url');
1112

@@ -2040,6 +2041,18 @@ describe('WebSocket', () => {
20402041
});
20412042
});
20422043
}).timeout(4000);
2044+
2045+
it('allows to disable sending the SNI extension', (done) => {
2046+
const original = tls.connect;
2047+
2048+
tls.connect = (options) => {
2049+
assert.strictEqual(options.servername, '');
2050+
tls.connect = original;
2051+
done();
2052+
};
2053+
2054+
const ws = new WebSocket('wss://127.0.0.1', { servername: '' });
2055+
});
20432056
});
20442057

20452058
describe('Request headers', () => {

0 commit comments

Comments
 (0)