summaryrefslogtreecommitdiff
path: root/test/parallel/test-tls-enable-keylog-cli.js
diff options
context:
space:
mode:
authorAlba Mendez <me@alba.sh>2020-05-12 14:53:12 +0200
committerAlba Mendez <me@alba.sh>2020-05-14 16:52:52 +0200
commit1dafaf03cb35d51562193afab6e903a10a89d906 (patch)
tree69b9c20bd21baf8132284a222f81497dda685f87 /test/parallel/test-tls-enable-keylog-cli.js
parent4ad26923f480197b16c11e8b7a493ed81b1326d5 (diff)
downloadnode-new-1dafaf03cb35d51562193afab6e903a10a89d906.tar.gz
tls: fix --tls-keylog option
There's a typo that causes only the first socket to be logged (i.e. when the warning is emitted). In addition, server sockets aren't logged because `keylog` events are not emitted on tls.Server, not the socket. This behaviour is counterintuitive and has caused more bugs in the past, so make all sockets (server or client) emit 'keylog'. tls.Server will just re-emit these events. Refs: https://github.com/nodejs/node/pull/30055 PR-URL: https://github.com/nodejs/node/pull/33366 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Diffstat (limited to 'test/parallel/test-tls-enable-keylog-cli.js')
-rw-r--r--test/parallel/test-tls-enable-keylog-cli.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/test/parallel/test-tls-enable-keylog-cli.js b/test/parallel/test-tls-enable-keylog-cli.js
index 5d05069b15..128d9a096a 100644
--- a/test/parallel/test-tls-enable-keylog-cli.js
+++ b/test/parallel/test-tls-enable-keylog-cli.js
@@ -24,8 +24,11 @@ const child = fork(__filename, ['test'], {
child.on('close', common.mustCall((code, signal) => {
assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
- const log = fs.readFileSync(file, 'utf8');
- assert(/SECRET/.test(log));
+ const log = fs.readFileSync(file, 'utf8').trim().split('\n');
+ // Both client and server should log their secrets,
+ // so we should have two identical lines in the log
+ assert.strictEqual(log.length, 2);
+ assert.strictEqual(log[0], log[1]);
}));
function test() {
@@ -40,7 +43,9 @@ function test() {
},
server: {
cert: keys.agent6.cert,
- key: keys.agent6.key
+ key: keys.agent6.key,
+ // Number of keylog events is dependent on protocol version
+ maxVersion: 'TLSv1.2',
},
}, common.mustCall((err, pair, cleanup) => {
if (pair.server.err) {