Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: check for tls renegotiation errors #25437

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 22 additions & 24 deletions test/parallel/test-tls-disable-renegotiation.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const tls = require('tls');

const options = {
key: fixtures.readKey('agent1-key.pem'),
cert: fixtures.readKey('agent1-cert.pem')
cert: fixtures.readKey('agent1-cert.pem'),
};

const server = tls.Server(options, common.mustCall((socket) => {
Expand Down Expand Up @@ -45,28 +45,26 @@ server.listen(0, common.mustCall(() => {
rejectUnauthorized: false,
port
};
const client =
tls.connect(options, common.mustCall(() => {
client.write('');
// Negotiation is still permitted for this first
// attempt. This should succeed.
client.renegotiate(
{ rejectUnauthorized: false },
common.mustCall(() => {
// Once renegotiation completes, we write some
// data to the socket, which triggers the on
// data event on the server. After that data
// is received, disableRenegotiation is called.
client.write('data', common.mustCall(() => {
client.write('');
// This second renegotiation attempt should fail
// and the callback should never be invoked. The
// server will simply drop the connection after
// emitting the error.
client.renegotiate(
{ rejectUnauthorized: false },
common.mustNotCall());
}));
}));
const client = tls.connect(options, common.mustCall(() => {
client.write('');
// Negotiation is still permitted for this first
// attempt. This should succeed.
let ok = client.renegotiate(options, common.mustCall((err) => {
assert.ifError(err);
// Once renegotiation completes, we write some
// data to the socket, which triggers the on
// data event on the server. After that data
// is received, disableRenegotiation is called.
client.write('data', common.mustCall(() => {
client.write('');
// This second renegotiation attempt should fail
// and the callback should never be invoked. The
// server will simply drop the connection after
// emitting the error.
ok = client.renegotiate(options, common.mustNotCall());
assert.strictEqual(ok, true);
}));
}));
assert.strictEqual(ok, true);
}));
}));