0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-tls-socket-failed-handshake-emits-error.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

39 lines
947 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const tls = require('tls');
const net = require('net');
const assert = require('assert');
const bonkers = Buffer.alloc(1024, 42);
const server = net.createServer(function(c) {
setTimeout(function() {
const s = new tls.TLSSocket(c, {
isServer: true,
server: server
});
s.on('error', common.mustCall(function(e) {
assert.ok(e instanceof Error,
'Instance of Error should be passed to error handler');
assert.ok(
/SSL routines:[^:]*:wrong version number/.test(
e.message),
'Expecting SSL unknown protocol');
}));
s.on('close', function() {
server.close();
s.destroy();
});
}, common.platformTimeout(200));
}).listen(0, function() {
const c = net.connect({ port: this.address().port }, function() {
c.write(bonkers);
});
});