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

Support SSL_CTX_set_keylog_callback #1349

Open
wants to merge 61 commits into
base: develop
Choose a base branch
from

Conversation

PatrickHMueller
Copy link

SSL_CTX_set_keylog_callback() sets the TLS key logging callback. This callback is called whenever TLS key material is generated or received, in order to allow applications to store this keying material for debugging purposes.

Manpage OpenSSL:

https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_keylog_callback.html

Debugging use-case:
Use Wireshark to inspect the MQTT connection at the packet level. It is helpful to decrypt the TLS packets. For this Wireshark needs the (Pre-) Master Secret. With this commit you can set the environment variable SSLKEYLOGFILE, give Wireshark the file and examine the decrypted MQTT packets.

https://wiki.wireshark.org/TLS

Thank you for your interest in this project managed by the Eclipse Foundation.

The guidelines for contributions can be found in the CONTRIBUTING.md file.

At a minimum, you must sign the Eclipse ECA, and sign off each commit.

To complete and submit a ECA, log into the Eclipse projects forge
You will need to create an account with the Eclipse Foundation if you have not already done so.
Be sure to use the same email address when you register for the account that you intend to use when you commit to Git.
Go to https://accounts.eclipse.org/user/eca to sign the Eclipse ECA.

@PatrickHMueller PatrickHMueller marked this pull request as draft April 21, 2023 09:19
SSL_CTX_set_keylog_callback() sets the TLS key logging callback. This callback is called whenever TLS key material is generated or received, in order to allow applications to store this keying material for debugging purposes.

Manpage OpenSSL:
https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_keylog_callback.html

SSL_CTX_set_keylog_callback is added to OpenSSL_1_1_1-pre1
openssl/openssl@2faa1b4

Debugging use-case:
Use Wireshark to inspect the MQTT connection at the packet level. It is helpful to decrypt the TLS packets. For this Wireshark needs the (Pre-) Master Secret. With this commit you can set the environment variable SSLKEYLOGFILE, give Wireshark the file and examine the decrypted MQTT packets.
https://wiki.wireshark.org/TLS

Signed-off-by: Patrick Mueller <patrick.mueller3@zf.com>
@PatrickHMueller PatrickHMueller marked this pull request as ready for review April 24, 2023 08:28
@PatrickHMueller
Copy link
Author

I see "2 workflows awaiting approval" what are the next steps to do? @icraggs can you help me it's the first PR for this project

icraggs and others added 27 commits October 9, 2023 14:57
Async sample callback context fix.
Signed-off-by: Michael Bleis <michael.bleis@aracom.de>
fptr = fopen(sslkeylogfile, "at");
if (fptr)
{
fprintf(fptr, "%s\n", line);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through and verified that this is the format that we should be logging, according to the OpenSSL docs:

The key logging callback is called with two items: the ssl object associated with the connection, and line, a string containing the key material in the format used by NSS for its SSLKEYLOGFILE debugging output. To recreate that file, the key logging callback should log line, followed by a newline. line will always be a NULL-terminated string.

FILE *fptr;

fptr = fopen(sslkeylogfile, "at");
if (fptr)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have an error log if the file failed to open, for example due to a permissions problem

  • Error log if keylog file can't be opened.

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 this pull request may close these issues.

None yet

9 participants