Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,8 @@ TLSSocket.prototype._init = function(socket, wrap) {
if (process.features.tls_sni &&
options.isServer &&
options.SNICallback &&
options.server &&
(options.SNICallback !== SNICallback ||
options.server._contexts.length)) {
(options.server && options.server._contexts.length))) {
assert(typeof options.SNICallback === 'function');
this._SNICallback = options.SNICallback;
ssl.enableCertCb();
Expand Down
26 changes: 26 additions & 0 deletions test/parallel/test-tls-socket-snicallback-without-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

// This is based on test-tls-securepair-fiftharg.js
// for the deprecated `tls.createSecurePair()` variant.

const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const assert = require('assert');
const tls = require('tls');
const fixtures = require('../common/fixtures');
const makeDuplexPair = require('../common/duplexpair');

const { clientSide, serverSide } = makeDuplexPair();
new tls.TLSSocket(serverSide, {
isServer: true,
SNICallback: common.mustCall((servername, cb) => {
assert.strictEqual('www.google.com', servername);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can you please swap the args?

})
});

// captured traffic from browser's request to https://www.google.com
const sslHello = fixtures.readSync('google_ssl_hello.bin');

clientSide.write(sslHello);