client/server: support for KeyLog trait, SSLKEYLOGFILE #465
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For debugging purposes it's quite helpful to be able to log session secrets to a file specified by the
SSLKEYLOGFILE
env var, for example to use with Wireshark to decrypt session traffic.This commit adds two methods to rustls-ffi for both client and server configurations to facilitate this:
rustls_server_config_builder_set_key_log_file()
andrustls_client_config_builder_set_key_log_file()
enable using the RustlsKeyLogFile
implementation of theKeyLog
trait. This option simply honours theSSLKEYLOGFILE
env var and spits out a NSS formatted key log file appropriate for use with Wireshark and other tools that support this format.rustls_server_config_builder_set_key_log()
andrustls_client_config_builder_set_key_log()
enable providing C callbacks that will be invoked to decide which secrets are logged, and to do the logging. This allows for fine-grained control over how secrets are logged and may be more appropriate for applications that already handle this task for other TLS backends (e.g. curl).The client and server examples are updated to optionally use these new features. If the
SSLKEYLOG
env. var is set, both will use the_set_key_log_file()
fns to set up the standard file based key logging. If theSTDERRKEYLOG
env var is set then both will use the_set_key_log()
fns to set up custom callbacks that will print the hex-encoded secret data to stderr as a simple demonstration.See the upstream
rustls::KeyLog
trait andrustls::KeyLogFile
implementation for more detail.