Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for KeyLogWriter #343

Closed
kegsay opened this issue Feb 3, 2021 · 1 comment
Closed

Add support for KeyLogWriter #343

kegsay opened this issue Feb 3, 2021 · 1 comment

Comments

@kegsay
Copy link
Contributor

kegsay commented Feb 3, 2021

Summary

TLS configs in Go have a KeyLogWriter which writes secrets for easy decryption later (e.g for use with Wireshark). This is similar to curl's SSLKEYLOGFILE= env var. Please can you add the ability to do this in dtls.Config.

Motivation

It's useful to be able to decrypt DTLS streams when debugging/testing. This feature is available in tls.Config - https://golang.org/pkg/crypto/tls/#Config

    // KeyLogWriter optionally specifies a destination for TLS master secrets
    // in NSS key log format that can be used to allow external programs
    // such as Wireshark to decrypt TLS connections.
    // See https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Key_Log_Format.
    // Use of KeyLogWriter compromises security and should only be
    // used for debugging.
    KeyLogWriter io.Writer // Go 1.8
@Sean-Der
Copy link
Member

Sean-Der commented Feb 3, 2021

I would love to accept a PR for this! You can intercept/write the values where it initialize the CipherSuite. here and here

I think you can accomplish what you want today with Export. The state doesn't export its members, but you can use reflection/unsafe to access the private members.

From there you have the keying material, CipherSuite and enough info to even assert if you lost any packets in your capture!

kegsay added a commit to kegsay/dtls that referenced this issue Feb 4, 2021
Fixes pion#343 - style is done in the same way as `tls.Config`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants