public static SSLContext createContext(final String keystoreProvider, final String keystorePath, final String keystorePassword, final String trustStoreProvider, final String trustStorePath, final String trustStorePassword, final boolean trustAll) throws Exception { return SSLSupport.createContext(keystoreProvider, keystorePath, keystorePassword, trustStoreProvider, trustStorePath, trustStorePassword, trustAll, null); }
engine.setEnabledCipherSuites(SSLSupport.parseCommaSeparatedListIntoArray(enabledCipherSuites)); } catch (IllegalArgumentException e) { ActiveMQClientLogger.LOGGER.invalidCipherSuite(SSLSupport.parseArrayIntoCommandSeparatedList(engine.getSupportedCipherSuites())); throw e; engine.setEnabledProtocols(SSLSupport.parseCommaSeparatedListIntoArray(enabledProtocols)); } catch (IllegalArgumentException e) { ActiveMQClientLogger.LOGGER.invalidProtocol(SSLSupport.parseArrayIntoCommandSeparatedList(engine.getSupportedProtocols())); throw e;
private void setupSsl() throws Exception { SSLContext context = new SSLSupport() .setKeystoreProvider(keyStoreProvider) .setKeystorePath(keyStorePath) .setKeystorePassword(keyStorePassword) .setTruststoreProvider(trustStoreProvider) .setTruststorePath(trustStorePath) .setTruststorePassword(trustStorePassword) .createContext(); SSLServerSocketFactory sssf = context.getServerSocketFactory(); RMIServerSocketFactory rssf = new ArtemisSslRMIServerSocketFactory(sssf, this.isClientAuth(), rmiServerHost); RMIClientSocketFactory rcsf = new SslRMIClientSocketFactory(); environment.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, rssf); environment.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, rcsf); }
SslContext context = new SSLSupport() .setKeystoreProvider(keystoreProvider) .setKeystorePath(keystorePath) .setKeystorePassword(keystorePassword) .setTruststoreProvider(truststoreProvider) .setTruststorePath(truststorePath) .setTruststorePassword(truststorePassword) .setSslProvider(sslProvider) .setTrustAll(trustAll) .createNettyClientContext();
if (kerb5Config == null && keyStorePath == null && TransportConstants.DEFAULT_TRUSTSTORE_PROVIDER.equals(keyStoreProvider)) throw new IllegalArgumentException("If \"" + TransportConstants.SSL_ENABLED_PROP_NAME + "\" is true then \"" + TransportConstants.KEYSTORE_PATH_PROP_NAME + "\" must be non-null " + "unless an alternative \"" + TransportConstants.KEYSTORE_PROVIDER_PROP_NAME + "\" has been specified."); context = new SSLSupport() .setKeystoreProvider(keyStoreProvider) .setKeystorePath(keyStorePath) .setKeystorePassword(keyStorePassword) .setTruststoreProvider(trustStoreProvider) .setTruststorePath(trustStorePath) .setTruststorePassword(trustStorePassword) .setSslProvider(sslProvider) .createNettyContext(); } catch (Exception e) { IllegalStateException ise = new IllegalStateException("Unable to create NettyAcceptor for " + host + ":" + port);
private BlockingConnection retrieveMQTTConnection(String host, String truststorePath, String truststorePass, String keystorePath, String keystorePass) throws Exception { MQTT mqtt = new MQTT(); mqtt.setConnectAttemptsMax(1); mqtt.setReconnectAttemptsMax(0); mqtt.setHost(host); SSLContext sslContext = new SSLSupport() .setKeystorePath(keystorePath) .setKeystorePassword(keystorePass) .setTruststorePath(truststorePath) .setTruststorePassword(truststorePass) .createContext(); mqtt.setSslContext(sslContext); BlockingConnection connection = mqtt.blockingConnection(); connection.connect(); return connection; }
@Test public void testOneWaySSLUsingDefaultSslContext() throws Exception { createCustomSslServer(); String text = RandomUtil.randomString(); tc.getParams().put(TransportConstants.SSL_ENABLED_PROP_NAME, true); tc.getParams().put(TransportConstants.USE_DEFAULT_SSL_CONTEXT_PROP_NAME, true); SSLContext.setDefault(new SSLSupport() .setTruststoreProvider(storeType) .setTruststorePath(CLIENT_SIDE_TRUSTSTORE) .setTruststorePassword(PASSWORD) .createContext()); ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(tc)); ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator)); ClientSession session = addClientSession(sf.createSession(false, true, true)); session.createQueue(CoreClientOverOneWaySSLTest.QUEUE, CoreClientOverOneWaySSLTest.QUEUE, false); ClientProducer producer = addClientProducer(session.createProducer(CoreClientOverOneWaySSLTest.QUEUE)); ClientMessage message = createTextMessage(session, text); producer.send(message); ClientConsumer consumer = addClientConsumer(session.createConsumer(CoreClientOverOneWaySSLTest.QUEUE)); session.start(); ClientMessage m = consumer.receive(1000); Assert.assertNotNull(m); Assert.assertEquals(text, m.getBodyBuffer().readString()); }
final SSLContext context; if (useSSL) { context = new SSLSupport() .setKeystorePath(SERVER_SIDE_KEYSTORE) .setKeystorePassword(PASSWORD) .createContext(); } else { context = null;
@Test public void testContextWithNullParameters() throws Exception { new SSLSupport().createContext(); }
context = SSLContext.getDefault(); } else { context = new SSLSupport() .setKeystoreProvider(keystoreProvider) .setKeystorePath(keystorePath) .setKeystorePassword(keystorePassword) .setTruststoreProvider(truststoreProvider) .setTruststorePath(truststorePath) .setTruststorePassword(truststorePassword) .setTrustAll(trustAll) .setCrlPath(crlPath) .createContext();
SslContext context = new SSLSupport() .setKeystoreProvider(keystoreProvider) .setKeystorePath(keystorePath) .setKeystorePassword(keystorePassword) .setTruststoreProvider(truststoreProvider) .setTruststorePath(truststorePath) .setTruststorePassword(truststorePassword) .setSslProvider(sslProvider) .setTrustAll(trustAll) .createNettyClientContext();
context = SSLContext.getDefault(); } else { context = new SSLSupport() .setKeystoreProvider(keystoreProvider) .setKeystorePath(keystorePath) .setKeystorePassword(keystorePassword) .setTruststoreProvider(truststoreProvider) .setTruststorePath(truststorePath) .setTruststorePassword(truststorePassword) .setTrustAll(trustAll) .setCrlPath(crlPath) .createContext();
SslContext context = new SSLSupport() .setKeystoreProvider(keystoreProvider) .setKeystorePath(keystorePath) .setKeystorePassword(keystorePassword) .setTruststoreProvider(truststoreProvider) .setTruststorePath(truststorePath) .setTruststorePassword(truststorePassword) .setSslProvider(sslProvider) .setTrustAll(trustAll) .createNettyClientContext();
engine.setEnabledCipherSuites(SSLSupport.parseCommaSeparatedListIntoArray(enabledCipherSuites)); } catch (IllegalArgumentException e) { ActiveMQServerLogger.LOGGER.invalidCipherSuite(SSLSupport.parseArrayIntoCommandSeparatedList(engine.getSupportedCipherSuites())); throw e; engine.setEnabledProtocols(SSLSupport.parseCommaSeparatedListIntoArray(enabledProtocols)); } catch (IllegalArgumentException e) { ActiveMQServerLogger.LOGGER.invalidProtocol(SSLSupport.parseArrayIntoCommandSeparatedList(engine.getSupportedProtocols())); throw e;
public static SSLContext createContext(final String keystoreProvider, final String keystorePath, final String keystorePassword, final String trustStoreProvider, final String trustStorePath, final String trustStorePassword, final String crlPath) throws Exception { return SSLSupport.createContext(keystoreProvider, keystorePath, keystorePassword, trustStoreProvider, trustStorePath, trustStorePassword, false, crlPath); }
context = SSLContext.getDefault(); } else { context = new SSLSupport() .setKeystoreProvider(keystoreProvider) .setKeystorePath(keystorePath) .setKeystorePassword(keystorePassword) .setTruststoreProvider(truststoreProvider) .setTruststorePath(truststorePath) .setTruststorePassword(truststorePassword) .setTrustAll(trustAll) .setCrlPath(crlPath) .createContext();
engine.setEnabledCipherSuites(SSLSupport.parseCommaSeparatedListIntoArray(enabledCipherSuites)); } catch (IllegalArgumentException e) { ActiveMQClientLogger.LOGGER.invalidCipherSuite(SSLSupport.parseArrayIntoCommandSeparatedList(engine.getSupportedCipherSuites())); throw e; engine.setEnabledProtocols(SSLSupport.parseCommaSeparatedListIntoArray(enabledProtocols)); } catch (IllegalArgumentException e) { ActiveMQClientLogger.LOGGER.invalidProtocol(SSLSupport.parseArrayIntoCommandSeparatedList(engine.getSupportedProtocols())); throw e;
context = SSLContext.getDefault(); } else { context = SSLSupport.createContext(realKeyStoreProvider, realKeyStorePath, realKeyStorePassword, realTrustStoreProvider, realTrustStorePath, realTrustStorePassword, trustAll, crlPath);
if (kerb5Config == null && keyStorePath == null && TransportConstants.DEFAULT_TRUSTSTORE_PROVIDER.equals(keyStoreProvider)) throw new IllegalArgumentException("If \"" + TransportConstants.SSL_ENABLED_PROP_NAME + "\" is true then \"" + TransportConstants.KEYSTORE_PATH_PROP_NAME + "\" must be non-null " + "unless an alternative \"" + TransportConstants.KEYSTORE_PROVIDER_PROP_NAME + "\" has been specified."); context = new SSLSupport() .setKeystoreProvider(keyStoreProvider) .setKeystorePath(keyStorePath) .setKeystorePassword(keyStorePassword) .setTruststoreProvider(trustStoreProvider) .setTruststorePath(trustStorePath) .setTruststorePassword(trustStorePassword) .setCrlPath(crlPath) .createContext(); } catch (Exception e) { IllegalStateException ise = new IllegalStateException("Unable to create NettyAcceptor for " + host + ":" + port);
engine.setEnabledCipherSuites(SSLSupport.parseCommaSeparatedListIntoArray(enabledCipherSuites)); } catch (IllegalArgumentException e) { ActiveMQClientLogger.LOGGER.invalidCipherSuite(SSLSupport.parseArrayIntoCommandSeparatedList(engine.getSupportedCipherSuites())); throw e; engine.setEnabledProtocols(SSLSupport.parseCommaSeparatedListIntoArray(enabledProtocols)); } catch (IllegalArgumentException e) { ActiveMQClientLogger.LOGGER.invalidProtocol(SSLSupport.parseArrayIntoCommandSeparatedList(engine.getSupportedProtocols())); throw e;