Skip to content

Commit c8ced8e

Browse files
committed
tls: renegotiate should take care of its own state
In the initial version of this test there were two zero-length writes to force tls state to cycle. The second is not necessary, at least not now, but the first was. The renegotiate() API should ensure that packet exchange takes place, not its users, so move the zero-length write into tls. See: nodejs#14239 See: nodejs@b1909d3a70f9
1 parent b4e670d commit c8ced8e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/_tls_wrap.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,9 @@ TLSSocket.prototype.renegotiate = function(options, callback) {
621621
this._requestCert = requestCert;
622622
this._rejectUnauthorized = rejectUnauthorized;
623623
}
624+
// Ensure that we'll cycle through internal openssl's state
625+
this.write('');
626+
624627
if (!this._handle.renegotiate()) {
625628
if (callback) {
626629
process.nextTick(callback, new ERR_TLS_RENEGOTIATE());

test/parallel/test-tls-disable-renegotiation.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ server.listen(0, common.mustCall(() => {
4646
port
4747
};
4848
const client = tls.connect(options, common.mustCall(() => {
49-
client.write('');
5049

5150
common.expectsError(() => client.renegotiate(), {
5251
code: 'ERR_INVALID_ARG_TYPE',
@@ -78,7 +77,6 @@ server.listen(0, common.mustCall(() => {
7877
// data event on the server. After that data
7978
// is received, disableRenegotiation is called.
8079
client.write('data', common.mustCall(() => {
81-
client.write('');
8280
// This second renegotiation attempt should fail
8381
// and the callback should never be invoked. The
8482
// server will simply drop the connection after

0 commit comments

Comments
 (0)