Skip to content

Instantly share code, notes, and snippets.

@omnisis
Last active November 20, 2020 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omnisis/10954630 to your computer and use it in GitHub Desktop.
Save omnisis/10954630 to your computer and use it in GitHub Desktop.
AMQ with SSL
<broker>
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
<transportConnector name="ssl" uri="ssl://0.0.0.0:61617?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600&amp;needClientAuth=true"/>
</transportConnectors>
<plugins>
<jaasDualAuthenticationPlugin configuration="activemq-domain" sslConfiguration="activemq-ssl-domain"/>
</plugins>
<sslContext>
<sslContext keyStore="${activemq.base}/conf/mybroker.ks" keyStorePassword="password"
trustStore="${activemq.base}/conf/mybroker.ts"
trustStorePassword="password" />
</sslContext>
</broker>
sslconsumer=CN=consumer, OU=test, O=test, L=Annapolis, ST=MD, C=US
sslproducer=CN=producer, OU=test, O=test, L=Annapolis, ST=MD, C=US
activemq-domain {
org.apache.activemq.jaas.PropertiesLoginModule required
org.apache.activemq.jaas.properties.user="users.properties"
org.apache.activemq.jaas.properties.group="groups.properties";
};
activemq-ssl-domain {
org.apache.activemq.jaas.TextFileCertificateLoginModule required
debug=true
org.apache.activemq.jaas.textfiledn.user="dns.properties"
org.apache.activemq.jaas.textfiledn.group="groups.properties";
};
package experiments
import org.apache.activemq.ActiveMQSslConnectionFactory
import org.apache.activemq.camel.component.ActiveMQComponent
import org.apache.activemq.camel.component.ActiveMQConfiguration
import org.apache.camel.Exchange
import org.apache.camel.Processor
import org.apache.camel.ProducerTemplate
import org.apache.camel.builder.RouteBuilder
import org.apache.camel.impl.DefaultCamelContext
import org.slf4j.LoggerFactory
def LOG = LoggerFactory.getLogger(this.class.name)
def amqBase = System.getProperty("activemq.base")
println "ActiveMQBase: ${amqBase}"
def trustStore = "${amqBase}/conf/myclient.ts"
def keyStore = "${amqBase}/conf/myproducer.ks"
def password = "password"
def connFactory = new ActiveMQSslConnectionFactory()
connFactory.trustStore = trustStore
connFactory.keyStore = keyStore
connFactory.keyStorePassword = password
connFactory.trustStorePassword = password
connFactory.setBrokerURL('ssl://localhost:61617')
camelCtx = new DefaultCamelContext()
amqConf = new ActiveMQConfiguration()
amqConf.setConnectionFactory(connFactory)
camelCtx.addComponent("amq", new ActiveMQComponent(amqConf))
camelCtx.addRoutes(new RouteBuilder() {
@Override
void configure() throws Exception {
LOG.info("configuring routes ...")
from("amq:queue:FOO")
.process(new Processor() {
@Override
void process(Exchange exchange) throws Exception {
LOG.info(exchange.getIn().getBody().toString())
}
})
}
})
camelCtx.start()
ProducerTemplate producerTemplate = camelCtx.createProducerTemplate()
producerTemplate.setDefaultEndpointUri("amq:queue:FOO")
// send some fake msgs
producerTemplate.sendBody("amq:queue:FOO", "This is a test!")
producerTemplate.sendBody("amq:queue:FOO", "This is another test")
LOG.info("Sent messages")
System.exit(0)
admin=admin
testuser=testuser
@miketzian
Copy link

Thanks for this, 5 years on this helped me figure out an issue. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment