Skip to content

Commit 8495a78

Browse files
sam-githubaddaleax
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 <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 5198297 commit 8495a78

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
@@ -613,6 +613,9 @@ TLSSocket.prototype.renegotiate = function(options, callback) {
613613
this._requestCert = requestCert;
614614
this._rejectUnauthorized = rejectUnauthorized;
615615
}
616+
// Ensure that we'll cycle through internal openssl's state
617+
this.write('');
618+
616619
if (!this._handle.renegotiate()) {
617620
if (callback) {
618621
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
// Negotiation is still permitted for this first
5150
// attempt. This should succeed.
5251
let ok = client.renegotiate(options, common.mustCall((err) => {
@@ -56,7 +55,6 @@ server.listen(0, common.mustCall(() => {
5655
// data event on the server. After that data
5756
// is received, disableRenegotiation is called.
5857
client.write('data', common.mustCall(() => {
59-
client.write('');
6058
// This second renegotiation attempt should fail
6159
// and the callback should never be invoked. The
6260
// server will simply drop the connection after

0 commit comments

Comments
 (0)