GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add key log callback option to SSLContext by chrisvest · Pull Request #861 · netty/netty-tcnative

Conversation

@chrisvest

@chrisvest chrisvest commented Mar 14, 2024

Copy link
Copy Markdown
Member

Motivation:
Wireshark can decrypt TLS sessions during packet capture, if the session keys (etc.) are available from an SSL key log file. This log file format has become a de facto industry standard, and BoringSSL (and maybe the others too, didn't check) has a callback mechanism for delivering log lines in this format.

Modification:
Add KeyLogCallback interface and an SSLContext.setKeyLogCallback method, which integrators can easily implement the SSLKEYLOGFILE feature, or equivalent, on top of.

Result:
It is now possible to configure netty-tcnative in a way that TLS sessions can be decrypted at packet-capture time by Wireshark, making it easier to investigate and debug problems with TLS.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@chrisvest
Add key log callback option to SSLContext
37a5846
Motivation:
Wireshark can decrypt TLS sessions during packet capture, if the session keys (etc.) are available from an SSL key log file.
This log file format has become a de facto industry standard, and BoringSSL (and maybe the others too, didn't check) has a callback mechanism for delivering log lines in this format.

Modification:
Add `KeyLogCallback` interface and an `SSLContext.setKeyLogCallback` method, which integrators can easily implement the SSLKEYLOGFILE feature, or equivalent, on top of.

Result:
It is now possible to configure netty-tcnative in a way that TLS sessions can be decrypted at packet-capture time by Wireshark, making it easier to investigate and debug problems with TLS.
@chrisvest
chrisvest requested a review from normanmaurer March 14, 2024 15:30
@chrisvest

chrisvest commented Mar 14, 2024

Copy link
Copy Markdown
Member Author

Maybe relevant to your interests as well, @hyperxpro.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisvest

chrisvest commented Mar 14, 2024

Copy link
Copy Markdown
Member Author

Not only a de facto standard, but perhaps on its way to becoming a formalized standard as well: https://datatracker.ietf.org/doc/draft-ietf-tls-keylogfile/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

normanmaurer
normanmaurer reviewed Mar 14, 2024
View reviewed changes
Comment thread openssl-classes/src/main/java/io/netty/internal/tcnative/KeyLogCallback.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

normanmaurer
normanmaurer approved these changes Mar 14, 2024
View reviewed changes

@normanmaurer normanmaurer left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Generally speaking looks good. Just two nits.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chrisvest reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread openssl-dynamic/src/main/c/sslcontext.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@hyperxpro

hyperxpro commented Mar 14, 2024

Copy link
Copy Markdown
Contributor

I will write an example for this and try to couple it with PcapWriteHandler.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisvest @normanmaurer
Apply suggestions from code review
395b93e
Co-authored-by: Norman Maurer <[email protected]>
@chrisvest
chrisvest merged commit 0cb6518 into main Mar 14, 2024
@chrisvest
chrisvest deleted the sslkeylogfile branch March 14, 2024 20:04
@chrisvest chrisvest added this to the 2.0.66.Final milestone Mar 14, 2024
@makkarpov

makkarpov commented Jun 26, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

For now, it seems like there is no public API to access the required context pointer.

long ctx is a protected field in io.netty.handler.ssl.ReferenceCountedOpenSslContext. Deprecated-but-public sslCtxPointer() is not an option, since function expects pointer to tcn_ssl_ctxt_t, not SSL_CTX. Attempt to use it will result in a segfault.

It looks like a reflective access to the private long ctx field is required to actually use this API. Luckily, Netty is an automatic module, and therefore is open by default. So this actually works without any --add-opens in modern JDKs. But still looks like a hack.

But otherwise the API works, thank you for implementing this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@idelpivnitskiy idelpivnitskiy mentioned this pull request Oct 21, 2026
Support SSLContext.setKeyLogCallback with OpenSSL 1.1.1+ #1021
Merged
normanmaurer added a commit that referenced this pull request Oct 23, 2026
@idelpivnitskiy @normanmaurer
Support SSLContext.setKeyLogCallback with OpenSSL 1.1.1+ (#1021)
d5d4cb0
Follow-up for #861.

Motivation:

`SSLContext.setKeyLogCallback` only works with BoringSSL and AWS-LC.
OpenSSL has had the same `SSL_CTX_set_keylog_callback` API since 1.1.1,
so `netty-tcnative-openssl-dynamic` users can't get SSLKEYLOGFILE-style
key logs.

Modification:

- Enable key logging for OpenSSL 1.1.1 and later (still not LibreSSL)
with a new `TCN_KEYLOG_SUPPORTED` macro.
- Weak-link `SSL_CTX_set_keylog_callback` with GCC/clang, and return
false if it's missing at runtime, like `setNumTickets`. MSVC builds use
the version check only.
- Document supported libraries, when false is returned, and the
callback's threading and exception behavior.
- Add tests that run real TLS 1.2 and 1.3 handshakes and check the key
log labels.

Result:

Key logging works with OpenSSL 1.1.1 and later. Weak linking covers
builds against older headers: the call returns false on an OpenSSL
runtime older than 1.1.1 and true on 1.1.1 or later.

Co-authored-by: Norman Maurer <[email protected]>
@normanmaurer normanmaurer mentioned this pull request Oct 30, 2026
jni util 0.0.12 #1039
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@normanmaurer normanmaurer normanmaurer approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

2.0.66.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@chrisvest @hyperxpro @makkarpov @normanmaurer
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.