Search in sources :

Example 1 with SslContext

use of org.apache.activemq.broker.SslContext in project activemq-artemis by apache.

the class FailoverStaticNetworkTest method setUp.

@Before
public void setUp() throws Exception {
    KeyManager[] km = SslBrokerServiceTest.getKeyManager();
    TrustManager[] tm = SslBrokerServiceTest.getTrustManager();
    sslContext = new SslContext(km, tm, null);
}
Also used : KeyManager(javax.net.ssl.KeyManager) TrustManager(javax.net.ssl.TrustManager) SslContext(org.apache.activemq.broker.SslContext) Before(org.junit.Before)

Example 2 with SslContext

use of org.apache.activemq.broker.SslContext in project camel by apache.

the class StompBaseTest method setUp.

@Override
public void setUp() throws Exception {
    port = AvailablePortFinder.getNextAvailable(61613);
    try {
        brokerService = new BrokerService();
        brokerService.setPersistent(false);
        brokerService.setAdvisorySupport(false);
        if (isUseSsl()) {
            SslContext sslContext = new SslContext();
            sslContext.setSSLContext(getServerSSLContext());
            brokerService.setSslContext(sslContext);
            brokerService.addConnector("stomp+ssl://localhost:" + getPort() + "?trace=true");
        } else {
            brokerService.addConnector("stomp://localhost:" + getPort() + "?trace=true");
        }
        brokerService.start();
        brokerService.waitUntilStarted();
        super.setUp();
        canTest = true;
    } catch (Exception e) {
        System.err.println("Cannot test due " + e.getMessage() + " more details in the log");
        log.warn("Cannot test due " + e.getMessage(), e);
        canTest = false;
    }
}
Also used : BrokerService(org.apache.activemq.broker.BrokerService) SslContext(org.apache.activemq.broker.SslContext)

Example 3 with SslContext

use of org.apache.activemq.broker.SslContext in project activemq-artemis by apache.

the class SslBrokerServiceTest method createBroker.

@Override
protected BrokerService createBroker() throws Exception {
    // http://java.sun.com/javase/javaseforbusiness/docs/TLSReadme.html
    // work around: javax.net.ssl.SSLHandshakeException: renegotiation is not allowed
    System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
    SslBrokerService service = new SslBrokerService();
    service.setPersistent(false);
    String baseUri = getBindLocation();
    String uri0 = baseUri + "?" + TransportConstants.SSL_ENABLED_PROP_NAME + "=true&" + TransportConstants.KEYSTORE_PATH_PROP_NAME + "=" + SslTransportBrokerTest.SERVER_KEYSTORE + "&" + TransportConstants.KEYSTORE_PASSWORD_PROP_NAME + "=" + SslTransportBrokerTest.PASSWORD + "&" + TransportConstants.KEYSTORE_PROVIDER_PROP_NAME + "=" + SslTransportBrokerTest.KEYSTORE_TYPE;
    String uri1 = uri0 + "&" + TransportConstants.ENABLED_CIPHER_SUITES_PROP_NAME + "=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,SSL_DH_anon_WITH_3DES_EDE_CBC_SHA";
    String uri2 = uri0 + "&" + TransportConstants.NEED_CLIENT_AUTH_PROP_NAME + "=true&" + TransportConstants.TRUSTSTORE_PATH_PROP_NAME + "=" + SslTransportBrokerTest.TRUST_KEYSTORE + "&" + TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME + "=" + SslTransportBrokerTest.PASSWORD + "&" + TransportConstants.TRUSTSTORE_PROVIDER_PROP_NAME + "=" + SslTransportBrokerTest.KEYSTORE_TYPE;
    // broker side
    TransportConnector serverConnector0 = service.addConnector(new URI(uri0));
    connector = new FakeTransportConnector(new URI("ssl://localhost:" + serverConnector0.getUri().getPort()));
    TransportConnector serverConnector1 = service.addConnector(new URI(uri1));
    limitedCipherSuites = new FakeTransportConnector(new URI("ssl://localhost:" + serverConnector1.getUri().getPort() + "?transport.enabledCipherSuites=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,SSL_DH_anon_WITH_3DES_EDE_CBC_SHA"));
    TransportConnector serverConnector2 = service.addConnector(new URI(uri2));
    needClientAuthConnector = new FakeTransportConnector(new URI("ssl://localhost:" + serverConnector2.getUri().getPort() + "?transport.needClientAuth=true"));
    KeyManager[] km = getKeyManager();
    TrustManager[] tm = getTrustManager();
    // for client side
    SslTransportFactory sslFactory = new SslTransportFactory();
    SslContext ctx = new SslContext(km, tm, null);
    SslContext.setCurrentSslContext(ctx);
    TransportFactory.registerTransportFactory("ssl", sslFactory);
    return service;
}
Also used : FakeTransportConnector(org.apache.activemq.broker.FakeTransportConnector) TransportConnector(org.apache.activemq.broker.TransportConnector) FakeTransportConnector(org.apache.activemq.broker.FakeTransportConnector) SslBrokerService(org.apache.activemq.broker.SslBrokerService) URI(java.net.URI) KeyManager(javax.net.ssl.KeyManager) TrustManager(javax.net.ssl.TrustManager) SslContext(org.apache.activemq.broker.SslContext)

Aggregations

SslContext (org.apache.activemq.broker.SslContext)3 KeyManager (javax.net.ssl.KeyManager)2 TrustManager (javax.net.ssl.TrustManager)2 URI (java.net.URI)1 BrokerService (org.apache.activemq.broker.BrokerService)1 FakeTransportConnector (org.apache.activemq.broker.FakeTransportConnector)1 SslBrokerService (org.apache.activemq.broker.SslBrokerService)1 TransportConnector (org.apache.activemq.broker.TransportConnector)1 Before (org.junit.Before)1