mirror of
https://github.com/nodejs/node.git
synced 2024-11-25 08:19:38 +01:00
3e1b1dd4a9
The copyright and license notice is already in the LICENSE file. There is no justifiable reason to also require that it be included in every file, since the individual files are not individually distributed except as part of the entire package.
43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
var common = require('../common');
|
|
|
|
if (!common.opensslCli) {
|
|
console.error('Skipping because node compiled without OpenSSL CLI.');
|
|
process.exit(0);
|
|
}
|
|
|
|
var assert = require('assert');
|
|
var fs = require('fs');
|
|
var tls = require('tls');
|
|
var spawn = require('child_process').spawn;
|
|
|
|
var success = false;
|
|
|
|
function filenamePEM(n) {
|
|
return require('path').join(common.fixturesDir, 'keys', n + '.pem');
|
|
}
|
|
|
|
function loadPEM(n) {
|
|
return fs.readFileSync(filenamePEM(n));
|
|
}
|
|
|
|
var server = tls.Server({
|
|
secureProtocol: 'TLSv1_2_server_method',
|
|
key: loadPEM('agent2-key'),
|
|
cert:loadPEM('agent2-cert')
|
|
}, null).listen(common.PORT, function() {
|
|
var args = ['s_client', '-quiet', '-tls1_1','-connect', '127.0.0.1:' + common.PORT];
|
|
var client = spawn(common.opensslCli, args);
|
|
var out = '';
|
|
client.stderr.setEncoding('utf8');
|
|
client.stderr.on('data', function(d) {
|
|
out += d;
|
|
if (/SSL alert number 70/.test(out)) {
|
|
success = true;
|
|
server.close();
|
|
}
|
|
});
|
|
});
|
|
process.on('exit', function() {
|
|
assert(success);
|
|
});
|