0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-tls-empty-sni-context.js
James M Snell 62611874d2 src: shift even moar x509 to ncrypto
PR-URL: https://github.com/nodejs/node/pull/54340
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2024-08-14 14:01:30 -07:00

34 lines
931 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, /no suitable signature algorithm/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) => {
const expectedErr = common.hasOpenSSL32 ?
'ERR_SSL_SSL/TLS_ALERT_HANDSHAKE_FAILURE' : 'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE';
assert.strictEqual(err.code, expectedErr);
}));
}));