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 — Clear certificate chain in setKeyMaterial. by mawiwill · Pull Request #987 · netty/netty-tcnative

Conversation

@mawiwill

@mawiwill mawiwill commented Jun 9, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Fixes #985.

Netty calls SSL.setKeyMaterial in its server-side certificate callback (https://docs.openssl.org/3.6/man3/SSL_CTX_set_cert_cb/ but the same going back to 1.0.2). OpenSSL invokes certificate callbacks after the server receives a ClientHello.

TLS 1.2 TLS sessions usually had one ClientHello, so this callback would usually run once. TLS 1.3, however, might begin a session with multiple ClientHellos as the result of
HelloRetryRequests. SSL.setKeyMaterial adds chained certificates (intermediates and roots) to the per-connection SSL struct with SSL_add1_chain_certs. This function appends certificates, so every time a ClientHello arrives, setKeyMaterial would re-add the same chain. Finicky clients fail if they receive the same intermediate twice.

This change allows netty-tcnative to talk TLS 1.3 with these clients. It clears the SSL struct's certificate chain (that is, everything after the certificate assigned with SSL_use_certificate) on every setKeyMaterial call. Multiple ClientHellos will result in the same key meterial appearing in Certificate responses.

Note that this should improve correctness for TLS 1.2, as well, since renegotiation for e.g. rekeying would have suffered from the same duplicate intermediates issue.

Sorry, something went wrong.

Uh oh!

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

All reactions
@mawiwill
Clear certificate chain in setKeyMaterial.
ae55677
Fixes netty#985.

Netty calls SSL.setKeyMaterial in its server-side certificate
callback (https://docs.openssl.org/3.6/man3/SSL_CTX_set_cert_cb/ but
the same going back to 1.0.2). OpenSSL invokes certificate callbacks
after the server receives a ClientHello.

TLS 1.2 TLS sessions usually had one ClientHello, so this callback
would usually run once. TLS 1.3, however, might begin a session with
multiple ClientHellos as the result of
HelloRetryRequests. SSL.setKeyMaterial adds chained
certificates (intermediates and roots) to the per-connection SSL
struct with SSL_add1_chain_certs. This function appends certificates,
so every time a ClientHello arrives, setKeyMaterial would re-add the
same chain. Finicky clients fail if they receive the same intermediate
twice.

This change allows netty-tcnative to talk TLS 1.3 with these
clients. It clears the SSL struct's certificate chain (that is,
everything after the certificate assigned with SSL_use_certificate) on
every setKeyMaterial call. Multiple ClientHellos will result in the
same key meterial appearing in Certificate responses.

Note that this should improve correctness for TLS 1.2, as well, since
renegotiation for e.g. rekeying would have suffered from the same
duplicate intermediates issue.
@mawiwill
mawiwill force-pushed the mawiwill/idempotent-cert-cb branch from 0ce2e0a to ae55677 Compare June 9, 2026 01:10
@mawiwill mawiwill changed the title Clear certificate chain in setKeyMaterial (#985). Clear certificate chain in setKeyMaterial. Jun 9, 2026
normanmaurer
normanmaurer reviewed Jun 9, 2026
View reviewed changes
Comment thread openssl-dynamic/src/main/c/ssl_private.h Outdated
#if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC)
#define tcn_SSL_add1_chain_cert(ssl, x509) SSL_add1_chain_cert(ssl, x509)
#define tcn_SSL_add0_chain_cert(ssl, x509) SSL_add0_chain_cert(ssl, x509)
#define tcn_SSL_clear_chain_certs(ssl) SSL_clear_chain_certs(ssl)

@normanmaurer normanmaurer Jun 9, 2026

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.

Why do we even need this and can't just call SSL_clear_chain_certs directly ?

Sorry, something went wrong.

Uh oh!

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

All reactions

@mawiwill mawiwill Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

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.

Only to mimic the code that's there already. I'm happy to remove it!

Sorry, something went wrong.

Uh oh!

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

All reactions

@normanmaurer normanmaurer Jun 9, 2026

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.

We only use our own defines if we need to use different APIs depending on which version / lib is used which seems to be not the case here and so we should just use SSL_clear_chain_certs directly.

Sorry, something went wrong.

Uh oh!

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

All reactions
normanmaurer
normanmaurer reviewed Jun 9, 2026
View reviewed changes
Comment thread openssl-dynamic/src/main/c/ssl.c Resolved

Uh oh!

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

normanmaurer
normanmaurer reviewed Jun 9, 2026
View reviewed changes
Comment thread openssl-dynamic/src/main/c/ssl.c Resolved

Uh oh!

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

Comment thread openssl-dynamic/src/main/c/ssl_private.h Resolved

Uh oh!

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

@normanmaurer
Apply suggestions from code review
651876c
Co-authored-by: Norman Maurer <[email protected]>
@normanmaurer

normanmaurer commented Jun 9, 2026

Copy link
Copy Markdown
Member

@mawiwill did you sign our ICLA yet ? https://netty.io/s/icla

All reactions

Sorry, something went wrong.

Uh oh!

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

@normanmaurer
Apply suggestion from @normanmaurer
b387dff
normanmaurer
normanmaurer reviewed Jun 9, 2026
View reviewed changes
Comment thread openssl-dynamic/src/main/c/ssl.c Resolved

Uh oh!

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

normanmaurer
normanmaurer reviewed Jun 9, 2026
View reviewed changes
Comment thread openssl-dynamic/src/main/c/ssl.c Resolved

Uh oh!

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

@normanmaurer
Add ifdef
a6ed949
@normanmaurer

normanmaurer commented Jun 9, 2026

Copy link
Copy Markdown
Member

@mawiwill PTAL

All reactions

Sorry, something went wrong.

Uh oh!

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

@mawiwill

mawiwill commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

ICLA

Just signed the ICLA!

All reactions

Sorry, something went wrong.

Uh oh!

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

chrisvest
chrisvest reviewed Jun 9, 2026
View reviewed changes

@chrisvest chrisvest 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.

Just one small nit

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread openssl-dynamic/src/main/c/ssl.c Resolved

Uh oh!

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

normanmaurer
normanmaurer reviewed Jun 9, 2026
View reviewed changes
Comment thread openssl-dynamic/src/main/c/ssl.c Resolved

Uh oh!

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

@normanmaurer
Update openssl-dynamic/src/main/c/ssl.c
67d068c
chrisvest
chrisvest approved these changes Jun 9, 2026
View reviewed changes
@mawiwill

mawiwill commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@mawiwill PTAL

This definitely works for me! I have a minor question about support OpenSSL versions, mostly out of curiosity. Thanks for your quick work on the PR, I really appreciate it!

All reactions

Sorry, something went wrong.

Uh oh!

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

@normanmaurer
normanmaurer merged commit 02d0d03 into netty:main Jun 10, 2026
10 checks passed

Uh oh!

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

@normanmaurer

normanmaurer commented Jun 10, 2026

Copy link
Copy Markdown
Member

@mawiwill thanks a lot!

All reactions

Sorry, something went wrong.

Uh oh!

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

@normanmaurer normanmaurer added this to the 2.0.79.Final milestone Jun 10, 2026
@dongjoon-hyun dongjoon-hyun mentioned this pull request Jun 24, 2026
[SPARK-57668][BUILD] Upgrade netty-tcnative to 2.0.79.Final apache/spark#56748
Closed
dongjoon-hyun added a commit to apache/spark that referenced this pull request Jun 24, 2026
@dongjoon-hyun
[SPARK-57668][BUILD] Upgrade netty-tcnative to 2.0.79.Final
fc1cc2e
### What changes were proposed in this pull request?

This PR aims to upgrade `netty-tcnative` to 2.0.79.Final.

### Why are the changes needed?

To bring the latest bug fixes. `netty-tcnative` 2.0.79.Final fixes BoringSSL
compatibility issues (incompatible weak symbol declarations and stale
`SSL_CREDENTIAL` support checks for older BoringSSL) and clears the certificate
chain in `setKeyMaterial`.
- https://github.com/netty/netty-tcnative/milestone/116 (2026-06-12)
  - netty/netty-tcnative#987
  - netty/netty-tcnative#986
  - netty/netty-tcnative#980

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass the CIs.

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Opus 4.8

Closes #56748 from dongjoon-hyun/SPARK-57668.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
This was referenced Aug 10, 2026
[fix][sec] Upgrade Netty to 4.2.17 to address several CVEs and bugs apache/pulsar#26300
Merged
[fix][sec][branch-4.2] Upgrade Netty to 4.1.137 to address several CVEs and bugs apache/pulsar#26301
Merged
@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 left review comments
@chrisvest chrisvest chrisvest 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.79.Final

Development

Successfully merging this pull request may close these issues.

HelloRetryRequest with TLS 1.3 can result in duplicate intermediate certs when tcnative is used with OpenSSL

Uh oh!

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

3 participants

@mawiwill @normanmaurer @chrisvest
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.