Skip to content

Commit 666beb0

Browse files
sam-githubdanbev
authored andcommitted
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: #14239 See: b1909d3a70f9 PR-URL: #25997 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 006e78c commit 666beb0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/_tls_wrap.js

+3
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

-2
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)