Skip to content

Commit bd68ff8

Browse files
committed
test: fix test-tls-junk-closes-server
Refs: #53382 TLS spec seems to indicate there should should be a response sent when TLS handshake fails. See https://datatracker.ietf.org/doc/html/rfc8446#page-85 When compiled with OpenSSL32 we see the the following response '15 03 03 00 02 02 16' which decodes as a fatal (0x02) TLS error alert number 22 (0x16). which corresponds to TLS1_AD_RECORD_OVERFLOW which matches the error we see if NODE_DEBUG is turned on once you get through the define aliases. If there is a response from the server the test used to hang because the end event will not be emitted until after the response is consumed. This PR fixes the test so it consumes the response. Some earlier OpenSSL versions did not seem to send a response but the error handling seems to have been re-written/improved in OpenSSL32. Signed-off-by: Michael Dawson <[email protected]>
1 parent f43424a commit bd68ff8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/parallel/test-tls-junk-closes-server.js

+16
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ const server = tls.createServer(options, common.mustNotCall());
3939
server.listen(0, common.mustCall(function() {
4040
const c = net.createConnection(this.address().port);
4141

42+
c.on('data', function () {
43+
// We must consume all data sent by the server. Otherwise the
44+
// end event will not be sent and the test will hang.
45+
// For example, when compiled with OpenSSL32 we see the
46+
// the following response '15 03 03 00 02 02 16' which
47+
// decodes as a fatal (0x02) TLS error alert number 22 (0x16).
48+
// which corresponds to TLS1_AD_RECORD_OVERFLOW which matches
49+
// the error we see if NODE_DEBUG is turned on.
50+
// Some earlier OpenSSL versions did not seem to send a response
51+
// but the TLS spec seems to indicate there should be one
52+
// https://datatracker.ietf.org/doc/html/rfc8446#page-85
53+
// and error handling seems to have been re-written/improved
54+
// in OpenSSL32. Consuming the data allows the test to pass
55+
// either way.
56+
});
57+
4258
c.on('connect', common.mustCall(function() {
4359
c.write('blah\nblah\nblah\n');
4460
}));

0 commit comments

Comments
 (0)