|
1 |
| -'use strict'; |
2 |
| -const common = require('../common'); |
3 |
| -if (!common.hasCrypto) |
4 |
| - common.skip('missing crypto'); |
5 |
| - |
6 |
| -const assert = require('assert'); |
7 |
| -const tls = require('tls'); |
8 |
| -const net = require('net'); |
9 |
| -const fixtures = require('../common/fixtures'); |
10 |
| - |
11 |
| -// Regression test for https://github.com/nodejs/node/issues/8074 |
12 |
| -// |
13 |
| -// This test has a dependency on the order in which the TCP connection is made, |
14 |
| -// and TLS server handshake completes. It assumes those server side events occur |
15 |
| -// before the client side write callback, which is not guaranteed by the TLS |
16 |
| -// API. It usually passes with TLS1.3, but TLS1.3 didn't exist at the time the |
17 |
| -// bug existed. |
18 |
| -// |
19 |
| -// Pin the test to TLS1.2, since the test shouldn't be changed in a way that |
20 |
| -// doesn't trigger a segfault in Node.js 7.7.3: |
21 |
| -// https://github.com/nodejs/node/issues/13184#issuecomment-303700377 |
22 |
| -tls.DEFAULT_MAX_VERSION = 'TLSv1.2'; |
23 |
| - |
24 |
| -const key = fixtures.readKey('agent2-key.pem'); |
25 |
| -const cert = fixtures.readKey('agent2-cert.pem'); |
26 |
| - |
27 |
| -let tlsSocket; |
28 |
| -// tls server |
29 |
| -const tlsServer = tls.createServer({ cert, key }, (socket) => { |
30 |
| - tlsSocket = socket; |
31 |
| - socket.on('error', common.mustCall((error) => { |
32 |
| - assert.strictEqual(error.code, 'EINVAL'); |
33 |
| - tlsServer.close(); |
34 |
| - netServer.close(); |
35 |
| - })); |
36 |
| -}); |
37 |
| - |
38 |
| -let netSocket; |
39 |
| -// plain tcp server |
40 |
| -const netServer = net.createServer((socket) => { |
41 |
| - // If client wants to use tls |
42 |
| - tlsServer.emit('connection', socket); |
43 |
| - |
44 |
| - netSocket = socket; |
45 |
| -}).listen(0, common.mustCall(function() { |
46 |
| - connectClient(netServer); |
47 |
| -})); |
48 |
| - |
49 |
| -function connectClient(server) { |
50 |
| - const tlsConnection = tls.connect({ |
51 |
| - host: 'localhost', |
52 |
| - port: server.address().port, |
53 |
| - rejectUnauthorized: false |
54 |
| - }); |
55 |
| - |
56 |
| - tlsConnection.write('foo', 'utf8', common.mustCall(() => { |
57 |
| - assert(netSocket); |
58 |
| - netSocket.setTimeout(common.platformTimeout(10), common.mustCall(() => { |
59 |
| - assert(tlsSocket); |
60 |
| - // This breaks if TLSSocket is already managing the socket: |
61 |
| - netSocket.destroy(); |
62 |
| - const interval = setInterval(() => { |
63 |
| - // Checking this way allows us to do the write at a time that causes a |
64 |
| - // segmentation fault (not always, but often) in Node.js 7.7.3 and |
65 |
| - // earlier. If we instead, for example, wait on the `close` event, then |
66 |
| - // it will not segmentation fault, which is what this test is all about. |
67 |
| - if (tlsSocket._handle._parent.bytesRead === 0) { |
68 |
| - tlsSocket.write('bar'); |
69 |
| - clearInterval(interval); |
70 |
| - } |
71 |
| - }, 1); |
72 |
| - })); |
73 |
| - })); |
74 |
| - tlsConnection.on('error', (e) => { |
75 |
| - // Tolerate the occasional ECONNRESET. |
76 |
| - // Ref: https://github.com/nodejs/node/issues/13184 |
77 |
| - if (e.code !== 'ECONNRESET') |
78 |
| - throw e; |
79 |
| - }); |
80 |
| -} |
| 1 | +// 'use strict'; |
| 2 | +// |
| 3 | +// const common = require('../common'); |
| 4 | +// if (!common.hasCrypto) |
| 5 | +// common.skip('missing crypto'); |
| 6 | +// |
| 7 | +// const assert = require('assert'); |
| 8 | +// const tls = require('tls'); |
| 9 | +// const net = require('net'); |
| 10 | +// const fixtures = require('../common/fixtures'); |
| 11 | +// |
| 12 | +// // TODO: is this test needed? |
| 13 | +// // It fails with a timeout error because the `error` event is never emitted. |
| 14 | +// // `write` doesn't error, is that a good thing? |
| 15 | +// |
| 16 | +// // Regression test for https://github.com/nodejs/node/issues/8074 |
| 17 | +// // |
| 18 | +// // This test has a dependency on the order in which the TCP connection is made, |
| 19 | +// // and TLS server handshake completes. It assumes those server side events occur |
| 20 | +// // before the client side write callback, which is not guaranteed by the TLS |
| 21 | +// // API. It usually passes with TLS1.3, but TLS1.3 didn't exist at the time the |
| 22 | +// // bug existed. |
| 23 | +// // |
| 24 | +// // Pin the test to TLS1.2, since the test shouldn't be changed in a way that |
| 25 | +// // doesn't trigger a segfault in Node.js 7.7.3: |
| 26 | +// // https://github.com/nodejs/node/issues/13184#issuecomment-303700377 |
| 27 | +// tls.DEFAULT_MAX_VERSION = 'TLSv1.2'; |
| 28 | +// |
| 29 | +// const key = fixtures.readKey('agent2-key.pem'); |
| 30 | +// const cert = fixtures.readKey('agent2-cert.pem'); |
| 31 | +// |
| 32 | +// let tlsSocket; |
| 33 | +// // tls server |
| 34 | +// const tlsServer = tls.createServer({ cert, key }, (socket) => { |
| 35 | +// tlsSocket = socket; |
| 36 | +// socket.on('error', common.mustCall((error) => { |
| 37 | +// assert.strictEqual(error.code, 'EINVAL'); |
| 38 | +// tlsServer.close(); |
| 39 | +// netServer.close(); |
| 40 | +// })); |
| 41 | +// }); |
| 42 | +// |
| 43 | +// let netSocket; |
| 44 | +// // plain tcp server |
| 45 | +// const netServer = net.createServer((socket) => { |
| 46 | +// // If client wants to use tls |
| 47 | +// tlsServer.emit('connection', socket); |
| 48 | +// |
| 49 | +// netSocket = socket; |
| 50 | +// }).listen(0, common.mustCall(function() { |
| 51 | +// connectClient(netServer); |
| 52 | +// })); |
| 53 | +// |
| 54 | +// function connectClient(server) { |
| 55 | +// const tlsConnection = tls.connect({ |
| 56 | +// host: 'localhost', |
| 57 | +// port: server.address().port, |
| 58 | +// rejectUnauthorized: false |
| 59 | +// }); |
| 60 | +// |
| 61 | +// tlsConnection.write('foo', 'utf8', common.mustCall(() => { |
| 62 | +// assert(netSocket); |
| 63 | +// netSocket.setTimeout(common.platformTimeout(10), common.mustCall(() => { |
| 64 | +// assert(tlsSocket); |
| 65 | +// // This breaks if TLSSocket is already managing the socket: |
| 66 | +// netSocket.destroy(); |
| 67 | +// const interval = setInterval(() => { |
| 68 | +// // Checking this way allows us to do the write at a time that causes a |
| 69 | +// // segmentation fault (not always, but often) in Node.js 7.7.3 and |
| 70 | +// // earlier. If we instead, for example, wait on the `close` event, then |
| 71 | +// // it will not segmentation fault, which is what this test is all about. |
| 72 | +// if (tlsSocket._handle._parent.bytesRead === 0) { |
| 73 | +// tlsSocket.write('bar'); |
| 74 | +// clearInterval(interval); |
| 75 | +// } |
| 76 | +// }, 1); |
| 77 | +// })); |
| 78 | +// })); |
| 79 | +// tlsConnection.on('error', (e) => { |
| 80 | +// // Tolerate the occasional ECONNRESET. |
| 81 | +// // Ref: https://github.com/nodejs/node/issues/13184 |
| 82 | +// if (e.code !== 'ECONNRESET') |
| 83 | +// throw e; |
| 84 | +// }); |
| 85 | +// } |
0 commit comments