Fix Bouncy Castle fips incompatible issue (#2740)

### Motivation

More details are provided in [Pulsar # 10937](

In #2631, the default BouncyCastle was changed from non-fips into fips version. But the default version of BouncyCastle in Pulsar is the [non-fips]( one(aimed to make it compatible with the old version of Pulsar). 

Bouncy Castle provides both FIPS and non-FIPS versions, but in a JVM, it can not include both of the 2 versions(non-Fips and Fips), and we have to exclude the current version before including the other. This makes the backward compatible a little hard, and that's why Pulsar has to involve an individual module for [Bouncy Castle](

And if we want to start BookKeeper with TLS enabled through Pulsar's binary, it will meet the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/bouncycastle/jcajce/provider/BouncyCastleFipsProvider
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(
	at org.apache.bookkeeper.common.util.ReflectionUtils.forName(
	at org.apache.bookkeeper.tls.SecurityProviderFactoryFactory.getSecurityProviderFactory(
	at org.apache.bookkeeper.proto.BookieServer.<init>(
	at org.apache.bookkeeper.server.service.BookieService.<init>(
	at org.apache.bookkeeper.server.Main.buildBookieServer(
	at org.apache.bookkeeper.server.Main.doMain(
	at org.apache.bookkeeper.server.Main.main(
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(
	at java.base/java.lang.ClassLoader.loadClass(
	... 9 more

This fix is to use the reflection to get the loaded bc version to avoid the hard-coded bc version.

### Changes

Use the reflection to get the loaded bc version to avoid the hard-coded bc version
Add backward compatible test for bc-non-fips version
5 files changed
tree: 47268a9a7e5ec989cd2c3934146f6b3f50246ef9
  1. .github/
  2. .gitignore
  3. .test-infra/
  4. Jenkinsfile
  8. bin/
  9. bookkeeper-benchmark/
  10. bookkeeper-common-allocator/
  11. bookkeeper-common/
  12. bookkeeper-dist/
  13. bookkeeper-http/
  14. bookkeeper-proto/
  15. bookkeeper-server/
  16. bookkeeper-stats-providers/
  17. bookkeeper-stats/
  18. build.gradle
  19. buildtools/
  20. circe-checksum/
  21. conf/
  22. cpu-affinity/
  23. dependencies.gradle
  24. deploy/
  25. dev/
  26. docker/
  28. gradle/
  29. gradlew
  30. gradlew.bat
  31. metadata-drivers/
  32. microbenchmarks/
  33. pom.xml
  34. settings.gradle
  35. shaded/
  36. site/
  37. site2/
  38. stats/
  39. stream/
  40. tests/
  41. tools/
  42. version.gradle

Build Status Build Status Coverage Status Maven Central

Apache BookKeeper

Apache BookKeeper is a scalable, fault tolerant and low latency storage service optimized for append-only workloads.

It is suitable for being used in following scenarios:

  • WAL (Write-Ahead-Logging), e.g. HDFS NameNode.
  • Message Store, e.g. Apache Pulsar.
  • Offset/Cursor Store, e.g. Apache Pulsar.
  • Object/Blob Store, e.g. storing state machine snapshots.

Get Started

  • Checkout the project website.
  • Concepts: Start with the basic concepts of Apache BookKeeper. This will help you to fully understand the other parts of the documentation.
  • Follow the Install guide to setup BookKeeper.


Please visit the Documentation from the project website for more information.

Get In Touch

Report a Bug

For filing bugs, suggesting improvements, or requesting new features, help us out by opening a Github issue or opening an Apache jira.

Need Help?

Subscribe or mail the list - Ask questions, find answers, and also help other users.

Subscribe or mail the list - Join development discussions, propose new ideas and connect with contributors.

Join us on Slack - This is the most immediate way to connect with Apache BookKeeper committers and contributors.


We feel that a welcoming open community is important and welcome contributions.

Contributing Code

  1. See Developer Setup to get your local environment setup.

  2. Take a look at our open issues: JIRA Issues Github Issues.

  3. Review our coding style and follow our pull requests to learn about our conventions.

  4. Make your changes according to our contribution guide.

Improving Website and Documentation

  1. See Building the website and documentation on how to build the website and documentation.