Author: gtully
Date: Tue Sep 11 12:07:35 2012
New Revision: 1383370

URL: http://svn.apache.org/viewvc?rev=1383370&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3989 - 
ActiveMQSslConnectionFactory.setKeyAndTrustManagers does not work with failover 
enabled - fix and test

Modified:
    
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSslConnectionFactory.java
    
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQSslConnectionFactoryTest.java

Modified: 
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSslConnectionFactory.java
URL: 
http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSslConnectionFactory.java?rev=1383370&r1=1383369&r2=1383370&view=diff
==============================================================================
--- 
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSslConnectionFactory.java
 (original)
+++ 
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSslConnectionFactory.java
 Tue Sep 11 12:07:35 2012
@@ -104,9 +104,9 @@ public class ActiveMQSslConnectionFactor
             if (keyStore != null || trustStore != null) {
                 keyManager = createKeyManager();
                 trustManager = createTrustManager();
-                if (keyManager != null || trustManager != null) {
-                    SslContext.setCurrentSslContext(new SslContext(keyManager, 
trustManager, secureRandom));
-                }
+            }
+            if (keyManager != null || trustManager != null) {
+                SslContext.setCurrentSslContext(new SslContext(keyManager, 
trustManager, secureRandom));
             }
             return super.createTransport();
         } catch (Exception e) {

Modified: 
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQSslConnectionFactoryTest.java
URL: 
http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQSslConnectionFactoryTest.java?rev=1383370&r1=1383369&r2=1383370&view=diff
==============================================================================
--- 
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQSslConnectionFactoryTest.java
 (original)
+++ 
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQSslConnectionFactoryTest.java
 Tue Sep 11 12:07:35 2012
@@ -25,6 +25,7 @@ import java.io.ObjectOutputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.security.KeyStore;
+import java.security.SecureRandom;
 
 import javax.jms.ExceptionListener;
 import javax.jms.JMSException;
@@ -129,6 +130,22 @@ public class ActiveMQSslConnectionFactor
         brokerStop();
     }
 
+    public void testFailoverSslConnectionWithKeyAndTrustManagers() throws 
Exception {
+        String sslUri = "ssl://localhost:61611";
+        broker = createSslBroker(sslUri);
+        assertNotNull(broker);
+
+        ActiveMQSslConnectionFactory cf = new 
ActiveMQSslConnectionFactory("failover:(" + sslUri + 
")?maxReconnectAttempts=4");
+        cf.setKeyAndTrustManagers(getKeyManager(), getTrustManager(), new 
SecureRandom());
+        connection = (ActiveMQConnection)cf.createConnection();
+        LOG.info("Created client connection");
+        assertNotNull(connection);
+        connection.start();
+        connection.stop();
+
+        brokerStop();
+    }
+
     public void testNegativeCreateSslConnectionWithWrongPassword() throws 
Exception {
         // Create SSL/TLS connection with trusted cert from truststore.
        String sslUri = "ssl://localhost:61611";


Reply via email to