0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-tls-client-renegotiation-13.js
Sam Roberts 8c69e06972 tls: return an OpenSSL error from renegotiate
A generic error lacks any of the context or detail of the underlying
OpenSSL error, so throw from C++, and report the OpenSSL error to the
callback.

PR-URL: https://github.com/nodejs/node/pull/26868
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2019-03-28 14:03:25 -07:00

42 lines
927 B
JavaScript

'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
// Confirm that for TLSv1.3, renegotiate() is disallowed.
const {
assert, connect, keys
} = require(fixtures.path('tls-connect'));
const server = keys.agent10;
connect({
client: {
ca: server.ca,
checkServerIdentity: common.mustCall(),
},
server: {
key: server.key,
cert: server.cert,
},
}, function(err, pair, cleanup) {
assert.ifError(err);
const client = pair.client.conn;
assert.strictEqual(client.getProtocol(), 'TLSv1.3');
const ok = client.renegotiate({}, common.mustCall((err) => {
assert.throws(() => { throw err; }, {
message: 'error:1420410A:SSL routines:SSL_renegotiate:wrong ssl version',
code: 'ERR_SSL_WRONG_SSL_VERSION',
library: 'SSL routines',
reason: 'wrong ssl version',
});
cleanup();
}));
assert.strictEqual(ok, false);
});