Skip to content

Commit

Permalink
Merge pull request #1165 from jbonofre/AMQ-9431
Browse files Browse the repository at this point in the history
AMQ-9431: Add org.apache.activemq.broker.BouncyCastleNotAdded system property to not load BouncyCastle in BrokerService
  • Loading branch information
jbonofre committed Mar 3, 2024
2 parents dcb660f + 0a90f32 commit a2fa433
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,20 @@ public class BrokerService implements Service {
static {

try {
ClassLoader loader = BrokerService.class.getClassLoader();
Class<?> clazz = loader.loadClass("org.bouncycastle.jce.provider.BouncyCastleProvider");
Provider bouncycastle = (Provider) clazz.getDeclaredConstructor().newInstance();
Integer bouncyCastlePosition = Integer.getInteger("org.apache.activemq.broker.BouncyCastlePosition");
int ret;
if (bouncyCastlePosition != null) {
ret = Security.insertProviderAt(bouncycastle, bouncyCastlePosition);
} else {
ret = Security.addProvider(bouncycastle);
Boolean bouncyCastleNotAdded = Boolean.getBoolean("org.apache.activemq.broker.BouncyCastleNotAdded");
if (bouncyCastleNotAdded == null || bouncyCastleNotAdded == false) {
ClassLoader loader = BrokerService.class.getClassLoader();
Class<?> clazz = loader.loadClass("org.bouncycastle.jce.provider.BouncyCastleProvider");
Provider bouncycastle = (Provider) clazz.getDeclaredConstructor().newInstance();
Integer bouncyCastlePosition = Integer.getInteger("org.apache.activemq.broker.BouncyCastlePosition");
int ret;
if (bouncyCastlePosition != null) {
ret = Security.insertProviderAt(bouncycastle, bouncyCastlePosition);
} else {
ret = Security.addProvider(bouncycastle);
}
LOG.info("Loaded the Bouncy Castle security provider at position: {}", ret);
}
LOG.info("Loaded the Bouncy Castle security provider at position: {}", ret);
} catch(Throwable e) {
// No BouncyCastle found so we use the default Java Security Provider
}
Expand Down

0 comments on commit a2fa433

Please sign in to comment.