1'use strict'; 2const common = require('../common'); 3if (!common.hasCrypto) 4 common.skip('missing crypto'); 5 6if (common.opensslCli === false) 7 common.skip('node compiled without OpenSSL CLI.'); 8 9const assert = require('assert'); 10const tls = require('tls'); 11const spawn = require('child_process').spawn; 12const fixtures = require('../common/fixtures'); 13 14const cert = fixtures.readKey('rsa_cert.crt'); 15const key = fixtures.readKey('rsa_private.pem'); 16const server = tls.createServer({ cert, key }, common.mustNotCall()); 17const errors = []; 18let stderr = ''; 19 20server.listen(0, '127.0.0.1', function() { 21 const address = `${this.address().address}:${this.address().port}`; 22 const args = ['s_client', 23 '-ssl3', 24 '-connect', address]; 25 26 const client = spawn(common.opensslCli, args, { stdio: 'pipe' }); 27 client.stdout.pipe(process.stdout); 28 client.stderr.pipe(process.stderr); 29 client.stderr.setEncoding('utf8'); 30 client.stderr.on('data', (data) => stderr += data); 31 32 client.once('exit', common.mustCall(function(exitCode) { 33 assert.strictEqual(exitCode, 1); 34 server.close(); 35 })); 36}); 37 38server.on('tlsClientError', (err) => errors.push(err)); 39 40process.on('exit', function() { 41 if (/[Uu]nknown option:? -ssl3/.test(stderr)) { 42 common.printSkipMessage('`openssl s_client -ssl3` not supported.'); 43 } else { 44 assert.strictEqual(errors.length, 1); 45 assert(/:version too low/.test(errors[0].message)); 46 } 47}); 48