mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
2d2986ae72
* Make common.skip() exit. Also add common.printSkipMessage() for partial skips. * Don't make needless things before skip PR-URL: https://github.com/nodejs/node/pull/14021 Fixes: https://github.com/nodejs/node/issues/14016 Reviewed-By: Refael Ackermann <refack@gmail.com>
35 lines
915 B
JavaScript
35 lines
915 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
if (!process.features.tls_sni)
|
|
common.skip('node compiled without OpenSSL or with old OpenSSL version.');
|
|
|
|
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(/SSL_use_certificate:passed a null parameter/i.test(err.message));
|
|
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(/socket hang up/.test(err.message));
|
|
}));
|
|
}));
|