0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-tls-no-sslv3.js
Tobias Nießen bc58a854e2
test: remove OpenSSL 1.0.2 error message compat
While upgrading from OpenSSL 1.0.2 to 1.1.1, these tests were modified
to recognize error messages from both OpenSSL releases. Given that
OpenSSL 1.0.2 has been unsupported for years, it is safe to remove the
older message patterns.

Refs: https://github.com/nodejs/node/pull/16130
PR-URL: https://github.com/nodejs/node/pull/46709
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2023-02-22 06:09:11 +00:00

48 lines
1.4 KiB
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
if (common.opensslCli === false)
common.skip('node compiled without OpenSSL CLI.');
const assert = require('assert');
const tls = require('tls');
const spawn = require('child_process').spawn;
const fixtures = require('../common/fixtures');
const cert = fixtures.readKey('rsa_cert.crt');
const key = fixtures.readKey('rsa_private.pem');
const server = tls.createServer({ cert, key }, common.mustNotCall());
const errors = [];
let stderr = '';
server.listen(0, '127.0.0.1', function() {
const address = `${this.address().address}:${this.address().port}`;
const args = ['s_client',
'-ssl3',
'-connect', address];
const client = spawn(common.opensslCli, args, { stdio: 'pipe' });
client.stdout.pipe(process.stdout);
client.stderr.pipe(process.stderr);
client.stderr.setEncoding('utf8');
client.stderr.on('data', (data) => stderr += data);
client.once('exit', common.mustCall(function(exitCode) {
assert.strictEqual(exitCode, 1);
server.close();
}));
});
server.on('tlsClientError', (err) => errors.push(err));
process.on('exit', function() {
if (/[Uu]nknown option:? -ssl3/.test(stderr)) {
common.printSkipMessage('`openssl s_client -ssl3` not supported.');
} else {
assert.strictEqual(errors.length, 1);
assert(/:version too low/.test(errors[0].message));
}
});