node/test/parallel/test-tls-empty-sni-context.js
Shelley Vohr 8e42d8c7bf
test: make more crypto tests work with BoringSSL
PR-URL: https://github.com/nodejs/node/pull/46429
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2023-02-01 19:51:39 +00:00

32 lines
814 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, /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.strictEqual(err.code, 'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE');
}));
}));