You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jb...@apache.org on 2024/03/03 16:04:39 UTC

(activemq) branch activemq-5.18.x updated: AMQ-9431: Add org.apache.activemq.broker.BouncyCastleNotAdded system property to not load BouncyCastle in BrokerService

This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch activemq-5.18.x
in repository https://gitbox.apache.org/repos/asf/activemq.git


The following commit(s) were added to refs/heads/activemq-5.18.x by this push:
     new 012cac88d AMQ-9431: Add org.apache.activemq.broker.BouncyCastleNotAdded system property to not load BouncyCastle in BrokerService
012cac88d is described below

commit 012cac88dc07a42dd55abff7af6f43228b960d66
Author: Jean-Baptiste Onofré <jb...@apache.org>
AuthorDate: Sat Mar 2 08:28:31 2024 +0100

    AMQ-9431: Add org.apache.activemq.broker.BouncyCastleNotAdded system property to not load BouncyCastle in BrokerService
    
    (cherry picked from commit 0a90f323ce5e7ad7d7ea555361afca6c2410f010)
---
 .../org/apache/activemq/broker/BrokerService.java  | 23 ++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java b/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
index 5ad7bf8c5..0fb262418 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
@@ -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
         }