mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-3989 - ActiveMQSslConnectionFactory.setKeyAndTrustManagers does not work with failover enabled - fix and test
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1383370 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f2225c2f12
commit
aaf03576ee
|
@ -104,9 +104,9 @@ public class ActiveMQSslConnectionFactory extends ActiveMQConnectionFactory {
|
|||
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) {
|
||||
|
|
|
@ -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 ActiveMQSslConnectionFactoryTest extends CombinationTestSupport {
|
|||
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";
|
||||
|
|
Loading…
Reference in New Issue