SslContext ctx = new SslContext(km, tm, random); SslContext.setCurrentSslContext(ctx); try {
/** * Overriding to make special considerations for SSL connections. If we are * not using SSL, the superclass's method is called. If we are using SSL, an * SslConnectionFactory is used and it is given the needed key and trust * managers. * * @author sepandm@gmail.com */ @Override protected Transport createTransport() throws JMSException { SslContext existing = SslContext.getCurrentSslContext(); try { if (keyStore != null || trustStore != null) { keyManager = createKeyManager(); trustManager = createTrustManager(); } if (keyManager != null || trustManager != null) { SslContext.setCurrentSslContext(new SslContext(keyManager, trustManager, secureRandom)); } return super.createTransport(); } catch (Exception e) { throw JMSExceptionSupport.create("Could not create Transport. Reason: " + e, e); } finally { SslContext.setCurrentSslContext(existing); } }
/** * * @param km * @param tm * @param random * @deprecated "Do not use anymore... using static initializers like this method only allows the JVM to use 1 SSL configuration per broker." * @see org.apache.activemq.broker.SslContext#setCurrentSslContext(SslContext) * @see org.apache.activemq.broker.SslContext#getSSLContext() */ public void setKeyAndTrustManagers(KeyManager[] km, TrustManager[] tm, SecureRandom random) { SslContext ctx = new SslContext(km, tm, random); SslContext.setCurrentSslContext(ctx); }
ConnectionFactory factory = new ActiveMQSslConnectionFactory(URL); sslContext.init(kmf.getKeyManagers(), trustAllCerts, new SecureRandom()); SslContext context = new SslContext(); context.setSSLContext(sslContext); SslContext.setCurrentSslContext(context);
SslContext ctx = new SslContext(km, tm, random); SslContext.setCurrentSslContext(ctx); try {
SslContext ctx = new SslContext(km, tm, random); SslContext.setCurrentSslContext(ctx); try {
SslContext ctx = new SslContext(km, tm, random); SslContext.setCurrentSslContext(ctx); try {
SslContext ctx = new SslContext(km, tm, random); SslContext.setCurrentSslContext(ctx); try {
/** * Overriding to make special considerations for SSL connections. If we are * not using SSL, the superclass's method is called. If we are using SSL, an * SslConnectionFactory is used and it is given the needed key and trust * managers. * * @author sepandm@gmail.com */ protected Transport createTransport() throws JMSException { // If the given URI is non-ssl, let superclass handle it. if (!brokerURL.getScheme().equals("ssl")) { return super.createTransport(); } try { if (keyManager == null || trustManager == null) { trustManager = createTrustManager(); keyManager = createKeyManager(); // secureRandom can be left as null } SslTransportFactory sslFactory = new SslTransportFactory(); SslContext ctx = new SslContext(keyManager, trustManager, secureRandom); SslContext.setCurrentSslContext(ctx); return sslFactory.doConnect(brokerURL); } catch (Exception e) { throw JMSExceptionSupport.create("Could not create Transport. Reason: " + e, e); } }
/** * Overriding to make special considerations for SSL connections. If we are * not using SSL, the superclass's method is called. If we are using SSL, an * SslConnectionFactory is used and it is given the needed key and trust * managers. * * @author sepandm@gmail.com */ @Override protected Transport createTransport() throws JMSException { SslContext existing = SslContext.getCurrentSslContext(); try { if (keyStore != null || trustStore != null) { keyManager = createKeyManager(); trustManager = createTrustManager(); } if (keyManager != null || trustManager != null) { SslContext.setCurrentSslContext(new SslContext(keyManager, trustManager, secureRandom)); } return super.createTransport(); } catch (Exception e) { throw JMSExceptionSupport.create("Could not create Transport. Reason: " + e, e); } finally { SslContext.setCurrentSslContext(existing); } }
/** * Overriding to make special considerations for SSL connections. If we are * not using SSL, the superclass's method is called. If we are using SSL, an * SslConnectionFactory is used and it is given the needed key and trust * managers. * * @author sepandm@gmail.com */ @Override protected Transport createTransport() throws JMSException { SslContext existing = SslContext.getCurrentSslContext(); try { if (keyStore != null || trustStore != null) { keyManager = createKeyManager(); trustManager = createTrustManager(); } if (keyManager != null || trustManager != null) { SslContext.setCurrentSslContext(new SslContext(keyManager, trustManager, secureRandom)); } return super.createTransport(); } catch (Exception e) { throw JMSExceptionSupport.create("Could not create Transport. Reason: " + e, e); } finally { SslContext.setCurrentSslContext(existing); } }
/** * Overriding to make special considerations for SSL connections. If we are * not using SSL, the superclass's method is called. If we are using SSL, an * SslConnectionFactory is used and it is given the needed key and trust * managers. * * @author sepandm@gmail.com */ @Override protected Transport createTransport() throws JMSException { SslContext existing = SslContext.getCurrentSslContext(); try { if (keyStore != null || trustStore != null) { keyManager = createKeyManager(); trustManager = createTrustManager(); } if (keyManager != null || trustManager != null) { SslContext.setCurrentSslContext(new SslContext(keyManager, trustManager, secureRandom)); } return super.createTransport(); } catch (Exception e) { throw JMSExceptionSupport.create("Could not create Transport. Reason: " + e, e); } finally { SslContext.setCurrentSslContext(existing); } }