From e80103a4cbee3db854b02030ba6544f8cc65b6b9 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 a25dfd45a3572e..96ec044cf7cc3e 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -708,6 +708,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`