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 2020/01/27 12:42:14 UTC

[activemq] branch master updated: AMQ-7142 - Inserting Bouncy Castle Provider Early in Java Security Provider Chain Breaks KeyStore Loading

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 127852d  AMQ-7142 - Inserting Bouncy Castle Provider Early in Java Security Provider Chain Breaks KeyStore Loading
     new b589b61  Merge pull request #431 from coheigea/AMQ-7142
127852d is described below

commit 127852d2e7098436e99c573bc7b30e3facdb634b
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Mon Jan 27 10:43:39 2020 +0000

    AMQ-7142 - Inserting Bouncy Castle Provider Early in Java Security Provider Chain Breaks KeyStore Loading
---
 .../main/java/org/apache/activemq/broker/BrokerService.java   | 11 ++++++++---
 .../src/test/java/org/apache/activemq/bugs/AMQ2902Test.java   |  2 +-
 2 files changed, 9 insertions(+), 4 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 df27da1..94cd81c 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
@@ -277,9 +277,14 @@ public class BrokerService implements Service {
             ClassLoader loader = BrokerService.class.getClassLoader();
             Class<?> clazz = loader.loadClass("org.bouncycastle.jce.provider.BouncyCastleProvider");
             Provider bouncycastle = (Provider) clazz.newInstance();
-            Security.insertProviderAt(bouncycastle,
-                Integer.getInteger("org.apache.activemq.broker.BouncyCastlePosition", 2));
-            LOG.info("Loaded the Bouncy Castle security provider.");
+            Integer bouncyCastlePosition = Integer.getInteger("org.apache.activemq.broker.BouncyCastlePosition");
+            int ret = 0;
+            if (bouncyCastlePosition != null) {
+                ret = Security.insertProviderAt(bouncycastle, bouncyCastlePosition);
+            } else {
+                ret = Security.addProvider(bouncycastle);
+            }
+            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
         }
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2902Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2902Test.java
index 3c38186..66ff094 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2902Test.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2902Test.java
@@ -55,7 +55,7 @@ public class AMQ2902Test extends TestCase {
                 LOG.error("got event: " + event + ", ex:" + event.getThrowableInformation().getThrowable(), event.getThrowableInformation().getThrowable());
                 LOG.error("Event source: ", new Throwable("Here"));
             }
-            if( !"Loaded the Bouncy Castle security provider.".equals(event.getMessage()) ) {
+            if( !((String) event.getMessage()).startsWith("Loaded the Bouncy Castle security provider at position") ) {
                 if (event.getMDC("activemq.broker") == null) {
                     failedToFindMDC.set(Boolean.TRUE);
                 }