From 01fa18c99cd076bb29b6f3bf3085319dcb4e4d95 Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Mon, 21 Oct 2019 20:44:20 -0700 Subject: [PATCH] tls: cli option to enable TLS key logging to file Debugging HTTPS or TLS connections from a Node.js app with (for example) Wireshark is unreasonably difficult without the ability to get the TLS key log. In theory, the application can be modified to use the `'keylog'` event directly, but for complex apps, or apps that define there own HTTPS Agent (like npm), this is unreasonably difficult. Use of the option triggers a warning to be emitted so the user is clearly notified of what is happening and its effect. PR-URL: https://github.com/nodejs/node/pull/30055 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Daniel Bevenius Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- doc/api/cli.md | 10 ++++ doc/node.1 | 5 ++ lib/_tls_wrap.js | 22 ++++++++ src/node_options.cc | 4 ++ src/node_options.h | 1 + test/parallel/test-tls-enable-keylog-cli.js | 57 +++++++++++++++++++++ 6 files changed, 99 insertions(+) create mode 100644 test/parallel/test-tls-enable-keylog-cli.js diff --git a/doc/api/cli.md b/doc/api/cli.md index e88b16b1ead80c..265139465363ac 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -679,6 +679,15 @@ added: v4.0.0 Specify an alternative default TLS cipher list. Requires Node.js to be built with crypto support (default). +### `--tls-keylog=file` + + +Log TLS key material to a file. The key material is in NSS `SSLKEYLOGFILE` +format and can be used by software (such as Wireshark) to decrypt the TLS +traffic. + ### `--tls-max-v1.2`