Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 12d76b8

Browse filesBrowse files
davedoesdevMylesBorins
authored andcommitted
tls: reset secureConnecting on client socket
secureConnecting is never set to false on client TLS sockets. So if Http2Session constructor (in lib/internal/http2/core.js) is called after secureConnect is emitted, then it will wrongly wait for a secureConnect event. This fix sets secureConnecting to false when a client TLS socket has connected. Backport-PR-URL: #34859 PR-URL: #33209 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
1 parent 70768ce commit 12d76b8
Copy full SHA for 12d76b8

File tree

Expand file treeCollapse file tree

2 files changed

+35
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+35
-1
lines changed
Open diff view settings
Collapse file

‎lib/_tls_wrap.js‎

Copy file name to clipboardExpand all lines: lib/_tls_wrap.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,10 +1523,12 @@ function onConnectSecure() {
15231523
debug('client emit secureConnect. rejectUnauthorized: %s, ' +
15241524
'authorizationError: %s', options.rejectUnauthorized,
15251525
this.authorizationError);
1526+
this.secureConnecting = false;
15261527
this.emit('secureConnect');
15271528
} else {
15281529
this.authorized = true;
15291530
debug('client emit secureConnect. authorized:', this.authorized);
1531+
this.secureConnecting = false;
15301532
this.emit('secureConnect');
15311533
}
15321534

Collapse file

‎test/parallel/test-http2-connect.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-connect.js
+33-1Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ const {
99
} = require('../common');
1010
if (!hasCrypto)
1111
skip('missing crypto');
12+
const fixtures = require('../common/fixtures');
1213
const assert = require('assert');
13-
const { createServer, connect } = require('http2');
14+
const { createServer, createSecureServer, connect } = require('http2');
1415
const { connect: netConnect } = require('net');
16+
const { connect: tlsConnect } = require('tls');
1517

1618
// Check for session connect callback and event
1719
{
@@ -70,6 +72,36 @@ const { connect: netConnect } = require('net');
7072
connect(authority).on('error', () => {});
7173
}
7274

75+
// Check for session connect callback on already connected TLS socket
76+
{
77+
const serverOptions = {
78+
key: fixtures.readKey('agent1-key.pem'),
79+
cert: fixtures.readKey('agent1-cert.pem')
80+
};
81+
const server = createSecureServer(serverOptions);
82+
server.listen(0, mustCall(() => {
83+
const { port } = server.address();
84+
85+
const onSocketConnect = () => {
86+
const authority = `https://localhost:${port}`;
87+
const createConnection = mustCall(() => socket);
88+
const options = { createConnection };
89+
connect(authority, options, mustCall(onSessionConnect));
90+
};
91+
92+
const onSessionConnect = (session) => {
93+
session.close();
94+
server.close();
95+
};
96+
97+
const clientOptions = {
98+
port,
99+
rejectUnauthorized: false
100+
};
101+
const socket = tlsConnect(clientOptions, mustCall(onSocketConnect));
102+
}));
103+
}
104+
73105
// Check for error for init settings error
74106
{
75107
createServer(function() {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.