2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-12-01 11:01:54 -05:00
|
|
|
const common = require('../common');
|
2025-01-24 16:58:32 -08:00
|
|
|
if (!common.hasCrypto) {
|
2016-05-11 15:34:52 -04:00
|
|
|
common.skip('missing crypto');
|
2025-01-24 16:58:32 -08:00
|
|
|
}
|
2015-03-04 12:11:21 +11:00
|
|
|
|
2025-01-24 16:58:32 -08:00
|
|
|
const { opensslCli } = require('../common/crypto');
|
|
|
|
|
|
|
|
if (opensslCli === false) {
|
2017-07-01 02:29:09 +03:00
|
|
|
common.skip('node compiled without OpenSSL CLI.');
|
2025-01-24 16:58:32 -08:00
|
|
|
}
|
2017-07-01 02:29:09 +03:00
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
const tls = require('tls');
|
2016-12-01 11:01:54 -05:00
|
|
|
const spawn = require('child_process').spawn;
|
2017-07-17 15:33:46 -07:00
|
|
|
const fixtures = require('../common/fixtures');
|
2015-01-13 00:45:31 +01:00
|
|
|
|
2019-05-29 11:43:44 -07:00
|
|
|
const cert = fixtures.readKey('rsa_cert.crt');
|
|
|
|
const key = fixtures.readKey('rsa_private.pem');
|
2018-01-11 19:03:58 +01:00
|
|
|
const server = tls.createServer({ cert, key }, common.mustNotCall());
|
2016-12-01 11:01:54 -05:00
|
|
|
const errors = [];
|
|
|
|
let stderr = '';
|
2015-01-13 00:45:31 +01:00
|
|
|
|
2016-05-29 03:06:56 -04:00
|
|
|
server.listen(0, '127.0.0.1', function() {
|
2017-04-28 04:06:42 +03:00
|
|
|
const address = `${this.address().address}:${this.address().port}`;
|
2016-12-01 11:01:54 -05:00
|
|
|
const args = ['s_client',
|
2016-12-31 21:39:57 -08:00
|
|
|
'-ssl3',
|
|
|
|
'-connect', address];
|
2015-07-18 11:59:55 +09:00
|
|
|
|
2025-01-24 16:58:32 -08:00
|
|
|
const client = spawn(opensslCli, args, { stdio: 'pipe' });
|
2015-12-08 23:46:07 +01:00
|
|
|
client.stdout.pipe(process.stdout);
|
|
|
|
client.stderr.pipe(process.stderr);
|
|
|
|
client.stderr.setEncoding('utf8');
|
2016-01-28 10:21:57 -05:00
|
|
|
client.stderr.on('data', (data) => stderr += data);
|
2015-12-08 23:46:07 +01:00
|
|
|
|
2015-01-13 00:45:31 +01:00
|
|
|
client.once('exit', common.mustCall(function(exitCode) {
|
2016-12-01 11:01:54 -05:00
|
|
|
assert.strictEqual(exitCode, 1);
|
2015-01-13 00:45:31 +01:00
|
|
|
server.close();
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
2016-01-28 10:21:57 -05:00
|
|
|
server.on('tlsClientError', (err) => errors.push(err));
|
2015-12-08 23:46:07 +01:00
|
|
|
|
|
|
|
process.on('exit', function() {
|
2021-04-01 16:18:28 +01:00
|
|
|
if (/[Uu]nknown option:? -ssl3/.test(stderr)) {
|
2017-07-01 02:29:09 +03:00
|
|
|
common.printSkipMessage('`openssl s_client -ssl3` not supported.');
|
2015-12-08 23:46:07 +01:00
|
|
|
} else {
|
2016-12-01 11:01:54 -05:00
|
|
|
assert.strictEqual(errors.length, 1);
|
2023-02-22 07:09:11 +01:00
|
|
|
assert(/:version too low/.test(errors[0].message));
|
2015-12-08 23:46:07 +01:00
|
|
|
}
|
|
|
|
});
|