mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
612307564b
The `test/common` module has the capability to identify if any variable is leaked to the global scope and fail the test. So that has to be imported at the beginning. PR-URL: https://github.com/nodejs/node/pull/7786 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
44 lines
1.0 KiB
JavaScript
44 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
if (!process.features.tls_sni) {
|
|
console.log('1..0 # Skipped: node compiled without OpenSSL or ' +
|
|
'with old OpenSSL version.');
|
|
return;
|
|
}
|
|
|
|
const assert = require('assert');
|
|
|
|
if (!common.hasCrypto) {
|
|
console.log('1..0 # Skipped: missing crypto');
|
|
return;
|
|
}
|
|
|
|
const tls = require('tls');
|
|
|
|
const options = {
|
|
SNICallback: (name, callback) => {
|
|
callback(null, tls.createSecureContext());
|
|
}
|
|
};
|
|
|
|
const server = tls.createServer(options, (c) => {
|
|
common.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.fail('Should not be called');
|
|
});
|
|
|
|
c.on('error', common.mustCall((err) => {
|
|
assert(/socket hang up/.test(err.message));
|
|
}));
|
|
}));
|