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

tls: renegotiate should take care of its own state #25997

Closed
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@ TLSSocket.prototype.renegotiate = function(options, callback) {
this._requestCert = requestCert;
this._rejectUnauthorized = rejectUnauthorized;
}
// Ensure that we'll cycle through internal openssl's state
this.write('');

if (!this._handle.renegotiate()) {
if (callback) {
process.nextTick(callback, new ERR_TLS_RENEGOTIATE());
Expand Down
2 changes: 0 additions & 2 deletions test/parallel/test-tls-disable-renegotiation.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ server.listen(0, common.mustCall(() => {
port
};
const client = tls.connect(options, common.mustCall(() => {
client.write('');

common.expectsError(() => client.renegotiate(), {
code: 'ERR_INVALID_ARG_TYPE',
Expand Down Expand Up @@ -78,7 +77,6 @@ server.listen(0, common.mustCall(() => {
// 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
Expand Down