node/test/parallel/test-tls-empty-sni-context.js
Michaël Zasso 508890d795
test: use assert.match instead of regexp.test
PR-URL: https://github.com/nodejs/node/pull/39928
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
2021-08-31 18:50:16 +02:00

32 lines
828 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const tls = require('tls');
const options = {
SNICallback: (name, callback) => {
callback(null, tls.createSecureContext());
}
};
const server = tls.createServer(options, (c) => {
assert.fail('Should not be called');
}).on('tlsClientError', common.mustCall((err, c) => {
assert.match(err.message, /SSL_use_certificate:passed a null parameter/i);
server.close();
})).listen(0, common.mustCall(() => {
const c = tls.connect({
port: server.address().port,
rejectUnauthorized: false,
servername: 'any.name'
}, common.mustNotCall());
c.on('error', common.mustCall((err) => {
assert.match(err.message, /Client network socket disconnected/);
}));
}));