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 — Always load BouncyCastle classes with the Netty classloader by chrisvest · Pull Request #15533 · netty/netty

Conversation

@chrisvest

@chrisvest chrisvest commented Aug 9, 2025

Copy link
Copy Markdown
Member

Motivation:
Between Java security settings, different classloaders, and native image compilation, loading the BouncyCastle classes are somewhat complicated.

Modification:
Collect all the BouncyCastle class loading and availability checking in a new BouncyCastleUtil class. Make use of this new class in our BouncyCastle implementations of ALPN, PEM reading, and self-signed certificate generation.

Result:
We should hopefully now be loading the classes correctly in all cases.

Fixes #15508

Sorry, something went wrong.

Uh oh!

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

All reactions
@chrisvest
Always load BouncyCastle classes with the Netty classloader
3506da0
Motivation:
Between Java security settings, different classloaders, and native image compilation, loading the BouncyCastle classes are somewhat complicated.

Modification:
Collect all the BouncyCastle class loading and availability checking in a new BouncyCastleUtil class.
Make use of this new class in our BouncyCastle implementations of ALPN, PEM reading, and self-signed certificate generation.

Result:
We should hopefully now be loading the classes correctly in all cases.

Fixes netty#15508
@chrisvest chrisvest added this to the 4.1.124.Final milestone Aug 9, 2025
@chrisvest
chrisvest requested a review from normanmaurer August 9, 2025 01:17
@chrisvest chrisvest mentioned this pull request Aug 9, 2025
BouncyCastleAlpnSslUtils static initializer fails when using a Security Properties file #15508
Closed
normanmaurer
normanmaurer reviewed Aug 11, 2025
View reviewed changes
Comment thread handler/src/main/java/io/netty/handler/ssl/util/BouncyCastleUtil.java Resolved

Uh oh!

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

@normanmaurer
Fix NPE
60cc6b0
normanmaurer
normanmaurer reviewed Aug 11, 2025
View reviewed changes
Comment thread handler/src/main/java/io/netty/handler/ssl/util/BouncyCastleUtil.java Resolved

Uh oh!

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

@normanmaurer
Fix copyright year
61a8b8b
normanmaurer
normanmaurer reviewed Aug 11, 2025
View reviewed changes
Comment thread handler/src/main/java/io/netty/handler/ssl/util/BouncyCastleUtil.java
/**
* Contains methods that can be used to detect if BouncyCastle is available.
*/
public final class BouncyCastleUtil {

@normanmaurer normanmaurer Aug 11, 2025

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.

@chrisvest is this really something we want to expose to the user ? Especially the reset method etc might make things easy to mess up for users.

Sorry, something went wrong.

Uh oh!

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

All reactions

@chrisvest chrisvest Aug 18, 2025

Copy link
Copy Markdown
Member 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.

We use BouncyCastle in two different packages. Either something needs to be public, or we duplicate the code.

Sorry, something went wrong.

Uh oh!

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

All reactions

@normanmaurer normanmaurer Aug 18, 2025

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.

I am not super happy that a user could call reset and so mess up things

Sorry, something went wrong.

Uh oh!

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

All reactions

@chrisvest chrisvest Aug 18, 2025

Copy link
Copy Markdown
Member 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.

The reset method is package-private, though. I can alternatively remove it and nerf the fields with reflection in the test.

Sorry, something went wrong.

Uh oh!

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

All reactions

@normanmaurer normanmaurer Aug 18, 2025

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.

Oh never mind then... did miss this.

Sorry, something went wrong.

Uh oh!

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

All reactions
normanmaurer
normanmaurer reviewed Aug 11, 2025
View reviewed changes
Comment thread handler/src/main/java/io/netty/handler/ssl/util/BouncyCastleUtil.java Resolved

Uh oh!

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

@normanmaurer
Update handler/src/main/java/io/netty/handler/ssl/util/BouncyCastleUt…
f9acbfd
…il.java
@normanmaurer normanmaurer modified the milestones: 4.1.124.Final, 4.1.125.Final Aug 13, 2025
normanmaurer
normanmaurer approved these changes Aug 18, 2025
View reviewed changes
@chrisvest
chrisvest merged commit 623d204 into netty:4.1 Aug 18, 2025
@chrisvest
chrisvest deleted the 4.1-bouncycastle-loading branch August 18, 2025 22:04
chrisvest added a commit to chrisvest/netty that referenced this pull request Aug 18, 2025
@chrisvest @normanmaurer
Always load BouncyCastle classes with the Netty classloader (netty#15533
fd956d9
)

Motivation:
Between Java security settings, different classloaders, and native image
compilation, loading the BouncyCastle classes are somewhat complicated.

Modification:
Collect all the BouncyCastle class loading and availability checking in
a new BouncyCastleUtil class. Make use of this new class in our
BouncyCastle implementations of ALPN, PEM reading, and self-signed
certificate generation.

Result:
We should hopefully now be loading the classes correctly in all cases.

Fixes netty#15508

---------

Co-authored-by: Norman Maurer <[email protected]>
normanmaurer added a commit that referenced this pull request Aug 19, 2025
@chrisvest @normanmaurer
Always load BouncyCastle classes with the Netty classloader (#15533) (#…
c90f2de
…15569)

Motivation:
Between Java security settings, different classloaders, and native image
compilation, loading the BouncyCastle classes are somewhat complicated.

Modification:
Collect all the BouncyCastle class loading and availability checking in
a new BouncyCastleUtil class. Make use of this new class in our
BouncyCastle implementations of ALPN, PEM reading, and self-signed
certificate generation.

Result:
We should hopefully now be loading the classes correctly in all cases.

Fixes #15508

Co-authored-by: Norman Maurer <[email protected]>
normanmaurer added a commit that referenced this pull request Aug 19, 2025
@chrisvest @normanmaurer
Always load BouncyCastle classes with the Netty classloader (#15533) (#…
74a2097
…15569)

Motivation:
Between Java security settings, different classloaders, and native image
compilation, loading the BouncyCastle classes are somewhat complicated.

Modification:
Collect all the BouncyCastle class loading and availability checking in
a new BouncyCastleUtil class. Make use of this new class in our
BouncyCastle implementations of ALPN, PEM reading, and self-signed
certificate generation.

Result:
We should hopefully now be loading the classes correctly in all cases.

Fixes #15508

Co-authored-by: Norman Maurer <[email protected]>
normanmaurer added a commit that referenced this pull request Aug 19, 2025
@normanmaurer @chrisvest
Always load BouncyCastle classes with the Netty classloader (#15533) … (
535b50f
#15570)

…(#15569)

Motivation:
Between Java security settings, different classloaders, and native image
compilation, loading the BouncyCastle classes are somewhat complicated.

Modification:
Collect all the BouncyCastle class loading and availability checking in
a new BouncyCastleUtil class. Make use of this new class in our
BouncyCastle implementations of ALPN, PEM reading, and self-signed
certificate generation.

Result:
We should hopefully now be loading the classes correctly in all cases.

Fixes #15508

Co-authored-by: Chris Vest <[email protected]>
@chrisvest chrisvest mentioned this pull request Aug 19, 2025
Always load BouncyCastle classes with the Netty classloader (#15533) … #15570
Merged
chrisvest added a commit to chrisvest/netty that referenced this pull request Aug 19, 2025
@chrisvest @normanmaurer
Always load BouncyCastle classes with the Netty classloader (netty#15533
b21980a
) (netty#15569)

Motivation:
Between Java security settings, different classloaders, and native image
compilation, loading the BouncyCastle classes are somewhat complicated.

Modification:
Collect all the BouncyCastle class loading and availability checking in
a new BouncyCastleUtil class. Make use of this new class in our
BouncyCastle implementations of ALPN, PEM reading, and self-signed
certificate generation.

Result:
We should hopefully now be loading the classes correctly in all cases.

Fixes netty#15508

Co-authored-by: Norman Maurer <[email protected]>
normanmaurer added a commit that referenced this pull request Aug 20, 2025
@chrisvest @normanmaurer
Always load BouncyCastle classes with the Netty classloader (#15533) (#…
cb84882
…15569) (#15572)

Motivation:
Between Java security settings, different classloaders, and native image
compilation, loading the BouncyCastle classes are somewhat complicated.

Modification:
Collect all the BouncyCastle class loading and availability checking in
a new BouncyCastleUtil class. Make use of this new class in our
BouncyCastle implementations of ALPN, PEM reading, and self-signed
certificate generation.

Result:
We should hopefully now be loading the classes correctly in all cases.

Fixes #15508

Co-authored-by: Norman Maurer <[email protected]>
@sberyozkin sberyozkin mentioned this pull request Sep 4, 2025
Regression in BouncyCastleAlpnSslUtils starting from 4.1.125.Final #15627
Closed
normanmaurer added a commit that referenced this pull request Sep 5, 2025
@normanmaurer
BouncyCastleAlpnSslUtils needs to use the correct SSLEngine class as …
74dd2ff
…otherwise it will fail to init static fields.

Motivation:

We recently did some changes related to how BouncyCastle is loaded and while doing so introduce a regression which would
cause NPE's later on once BouncyCastle was detected and used and we tried to apply ALPN later on. This regression was introduced by
#15533

The problem was that we used the wrong class to try to obtain the Method instances via reflection. This failed as the class itself is package-private
and so did not allow to access the methods. To fix this we need to ensure we use the public interface that is used by BouncyCastle and not the implemention
class itself. Beside this we also should be more defensive and only try to use ALPN via BouncyCastle if we can obtain the Methods in the first place.

Modifications:

- Fix refelective access
- Add more guards
- Add unit test

Result:

Fixes #15627

Result:

After your change, what will change.
@normanmaurer normanmaurer mentioned this pull request Sep 5, 2025
BouncyCastleAlpnSslUtils needs to use the correct SSLEngine class as … #15628
Merged
normanmaurer added a commit that referenced this pull request Sep 5, 2025
@normanmaurer
BouncyCastleAlpnSslUtils needs to use the correct SSLEngine class as …
a5f5f48
…otherwise it will fail to init static fields.

Motivation:

We recently did some changes related to how BouncyCastle is loaded and while doing so introduce a regression which would
cause NPE's later on once BouncyCastle was detected and used and we tried to apply ALPN later on. This regression was introduced by
#15533

The problem was that we used the wrong class to try to obtain the Method instances via reflection. This failed as the class itself is package-private
and so did not allow to access the methods. To fix this we need to ensure we use the public interface that is used by BouncyCastle and not the implemention
class itself. Beside this we also should be more defensive and only try to use ALPN via BouncyCastle if we can obtain the Methods in the first place.

Modifications:

- Fix refelective access
- Add more guards
- Add unit test

Result:

Fixes #15627

Result:

After your change, what will change.
normanmaurer added a commit that referenced this pull request Sep 5, 2025
@normanmaurer
BouncyCastleAlpnSslUtils needs to use the correct SSLEngine class as …
8307c15
…otherwise it will fail to init static fields.

Motivation:

We recently did some changes related to how BouncyCastle is loaded and while doing so introduce a regression which would
cause NPE's later on once BouncyCastle was detected and used and we tried to apply ALPN later on. This regression was introduced by
#15533

The problem was that we used the wrong class to try to obtain the Method instances via reflection. This failed as the class itself is package-private
and so did not allow to access the methods. To fix this we need to ensure we use the public interface that is used by BouncyCastle and not the implemention
class itself. Beside this we also should be more defensive and only try to use ALPN via BouncyCastle if we can obtain the Methods in the first place.

Modifications:

- Fix refelective access
- Add more guards
- Add unit test

Result:

Fixes #15627

Result:

After your change, what will change.
normanmaurer added a commit that referenced this pull request Sep 5, 2025
@normanmaurer
BouncyCastleAlpnSslUtils needs to use the correct SSLEngine class as …
1a4c690
…otherwise it will fail to init static fields.

Motivation:

We recently did some changes related to how BouncyCastle is loaded and while doing so introduce a regression which would
cause NPE's later on once BouncyCastle was detected and used and we tried to apply ALPN later on. This regression was introduced by
#15533

The problem was that we used the wrong class to try to obtain the Method instances via reflection. This failed as the class itself is package-private
and so did not allow to access the methods. To fix this we need to ensure we use the public interface that is used by BouncyCastle and not the implemention
class itself. Beside this we also should be more defensive and only try to use ALPN via BouncyCastle if we can obtain the Methods in the first place.

Modifications:

- Fix refelective access
- Add more guards
- Add unit test

Result:

Fixes #15627

Result:

After your change, what will change.
normanmaurer added a commit that referenced this pull request Sep 5, 2025
@normanmaurer
BouncyCastleAlpnSslUtils needs to use the correct SSLEngine class as …
45612f0
…otherwise it will fail to init static fields.

Motivation:

We recently did some changes related to how BouncyCastle is loaded and while doing so introduce a regression which would
cause NPE's later on once BouncyCastle was detected and used and we tried to apply ALPN later on. This regression was introduced by
#15533

The problem was that we used the wrong class to try to obtain the Method instances via reflection. This failed as the class itself is package-private
and so did not allow to access the methods. To fix this we need to ensure we use the public interface that is used by BouncyCastle and not the implemention
class itself. Beside this we also should be more defensive and only try to use ALPN via BouncyCastle if we can obtain the Methods in the first place.

Modifications:

- Fix refelective access
- Add more guards
- Add unit test

Result:

Fixes #15627

Result:

After your change, what will change.
@normanmaurer normanmaurer mentioned this pull request Sep 5, 2025
BouncyCastleAlpnSslUtils needs to use the correct SSLEngine class as … #15630
Merged
normanmaurer added a commit that referenced this pull request Sep 5, 2025
@normanmaurer
BouncyCastleAlpnSslUtils needs to use the correct SSLEngine class as … (
d60b1ba
#15628)

…otherwise it will fail to init static fields.

Motivation:

We recently did some changes related to how BouncyCastle is loaded and
while doing so introduce a regression which would cause NPE's later on
once BouncyCastle was detected and used and we tried to apply ALPN later
on. This regression was introduced by
#15533

The problem was that we used the wrong class to try to obtain the Method
instances via reflection. This failed as the class itself is
package-private and so did not allow to access the methods. To fix this
we need to ensure we use the public interface that is used by
BouncyCastle and not the implemention class itself. Beside this we also
should be more defensive and only try to use ALPN via BouncyCastle if we
can obtain the Methods in the first place.

Modifications:

- Fix refelective access
- Add more guards
- Add unit test

Result:

Fixes #15627
normanmaurer added a commit that referenced this pull request Sep 8, 2025
@normanmaurer
BouncyCastleAlpnSslUtils needs to use the correct SSLEngine class as … (
bbacc6b
#15630)

…otherwise it will fail to init static fields.

Motivation:

We recently did some changes related to how BouncyCastle is loaded and
while doing so introduce a regression which would cause NPE's later on
once BouncyCastle was detected and used and we tried to apply ALPN later
on. This regression was introduced by
#15533

The problem was that we used the wrong class to try to obtain the Method
instances via reflection. This failed as the class itself is
package-private and so did not allow to access the methods. To fix this
we need to ensure we use the public interface that is used by
BouncyCastle and not the implemention class itself. Beside this we also
should be more defensive and only try to use ALPN via BouncyCastle if we
can obtain the Methods in the first place.

Modifications:

- Fix refelective access
- Add more guards
- Add unit test

Result:

Fixes #15627
cmark added a commit to b2ihealthcare/snow-owl that referenced this pull request Apr 1, 2026
@cmark
chore(core): explicitly add BouncyCastleProvider to Java Security...
efb1991
...when initializing self-signed certs

Required as Netty changed BC Provider class loading logic in release
4.1.125.Final, see here: netty/netty#15533
This was referenced Sep 14, 2026
Http2: Reserve promised stream for PUSH_PROMISE after local RST_STREAM #17471
Closed
cache failure 1233e4a5 #17565
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

4.1.125.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

2 participants

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