2016-05-20 02:25:05 +02:00
|
|
|
'use strict';
|
|
|
|
|
2016-07-18 22:33:42 +02:00
|
|
|
const common = require('../common');
|
|
|
|
|
2016-05-20 02:25:05 +02:00
|
|
|
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();
|
2016-05-29 09:06:56 +02:00
|
|
|
})).listen(0, common.mustCall(() => {
|
2016-05-20 02:25:05 +02:00
|
|
|
const c = tls.connect({
|
2016-05-29 09:06:56 +02:00
|
|
|
port: server.address().port,
|
2016-05-20 02:25:05 +02:00
|
|
|
rejectUnauthorized: false,
|
|
|
|
servername: 'any.name'
|
|
|
|
}, () => {
|
|
|
|
common.fail('Should not be called');
|
|
|
|
});
|
|
|
|
|
|
|
|
c.on('error', common.mustCall((err) => {
|
|
|
|
assert(/socket hang up/.test(err.message));
|
|
|
|
}));
|
|
|
|
}));
|