GeezerVison is showing github.com — test: fix test-tls-junk-closes-server · nodejs/node@7802170
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-tls-junk-closes-server.js +16Lines changed: 16 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -39,6 +39,22 @@ const server = tls.createServer(options, common.mustNotCall()); |
39 | 39 | server.listen(0, common.mustCall(function() { |
40 | 40 | const c = net.createConnection(this.address().port); |
41 | 41 |
|
| 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 | + // 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 | + |
42 | 58 | c.on('connect', common.mustCall(function() { |
43 | 59 | c.write('blah\nblah\nblah\n'); |
44 | 60 | })); |
|