0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-25 08:19:38 +01:00
nodejs/test/parallel/test-tls-no-sslv3.js
Shigeki Ohtsu c86e383c41 test: fix test failure with shared openssl
When configured with share openssl, use external openssl command and
check if it can be executed.

Fixes: https://github.com/iojs/io.js/issues/618
PR-URL: https://github.com/iojs/io.js/pull/762
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-02-10 01:24:02 +09:00

40 lines
1.2 KiB
JavaScript

if (!process.versions.openssl) {
console.error('Skipping because node compiled without OpenSSL.');
process.exit(0);
}
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
var spawn = require('child_process').spawn;
var tls = require('tls');
if (common.opensslCli === false) {
console.error('Skipping because openssl command cannot be executed');
process.exit(0);
}
var cert = fs.readFileSync(common.fixturesDir + '/test_cert.pem');
var key = fs.readFileSync(common.fixturesDir + '/test_key.pem');
var server = tls.createServer({ cert: cert, key: key }, assert.fail);
server.listen(common.PORT, '127.0.0.1', function() {
var address = this.address().address + ':' + this.address().port;
var args = ['s_client',
'-no_ssl2',
'-ssl3',
'-no_tls1',
'-no_tls1_1',
'-no_tls1_2',
'-connect', address];
var client = spawn(common.opensslCli, args, { stdio: 'inherit' });
client.once('exit', common.mustCall(function(exitCode) {
assert.equal(exitCode, 1);
server.close();
}));
});
server.once('clientError', common.mustCall(function(err, conn) {
assert(/SSL3_GET_CLIENT_HELLO:wrong version number/.test(err.message));
}));