You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by mrich <ma...@qxlva.com> on 2013/11/04 11:49:11 UTC

Instantiating ActiveMQSslConnectionFactory via JNDI (SSL)

Hi,

I am trying to create a secure ActiveMQ connection, using
ActiveMQSslConnectionFactory that I want instantiated from JNDI.
	
I have got JNDI working to lookup a standard ActiveMQ connection factory,
however I am having problems updating this to create an
ActiveMQSslConnectionFactory, whereby I can then programatically set
keystore/truststore information.


A sample of my code is:

/Hashtable<String, String> environmentVariables = new Hashtable<String,
String>();
environmentVariables.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
environmentVariables.put(Context.PROVIDER_URL, "ssl:/...");

initialContext = new InitialContext(environmentVariables);
QueueConnectionFactory connectionFactory =
initialContext.lookup("QueueConnectionFactory");/

This works fine, but I end up with a 'QueueConnectionFactory'. I can use the
other 'lookup' options but that just gives me an ActiveMQConnectionFactory
or the TopicConnectionFactory... but not the ActiveMQSslConnectionFactory
that I require.


Any guidance is appreciated.



--
View this message in context: http://activemq.2283324.n4.nabble.com/Instantiating-ActiveMQSslConnectionFactory-via-JNDI-SSL-tp4673824.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Instantiating ActiveMQSslConnectionFactory via JNDI (SSL)

Posted by Gary Tully <ga...@gmail.com>.
the brokerUrl is the only property that should use the ssl scheme.
Destinations are protocol agnostic.
consider that the ActiveMQInitialContextFactory is really just a fancy
hashmap with some predefined keys, it does
not represent the state on the broker because the broker will create
destinations on demand.
So it is really just a simple facade in cases where jndi is required.
peek at the implementation to further understand:
https://github.com/apache/activemq/blob/trunk/activemq-client/src/main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java#L57

On 5 November 2013 10:38, mrich <ma...@qxlva.com> wrote:
> Thanks for the reply,
>
> I have gone with instantiating the SSL factory variant in the code as you
> suggested, however I have always used JNDI to lookup a Destination (dynamic
> queues), which doesn't seem to play nice with the SSL protocol. (Get a
> malformed URL exception, unknownn protocol ssl).
>
> What is the best way to establish the connection to a Destination using SSL
> ?
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Instantiating-ActiveMQSslConnectionFactory-via-JNDI-SSL-tp4673824p4673893.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.



-- 
http://redhat.com
http://blog.garytully.com

Re: Instantiating ActiveMQSslConnectionFactory via JNDI (SSL)

Posted by mrich <ma...@qxlva.com>.
Thanks for the reply,

I have gone with instantiating the SSL factory variant in the code as you
suggested, however I have always used JNDI to lookup a Destination (dynamic
queues), which doesn't seem to play nice with the SSL protocol. (Get a
malformed URL exception, unknownn protocol ssl).

What is the best way to establish the connection to a Destination using SSL
?



--
View this message in context: http://activemq.2283324.n4.nabble.com/Instantiating-ActiveMQSslConnectionFactory-via-JNDI-SSL-tp4673824p4673893.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Instantiating ActiveMQSslConnectionFactory via JNDI (SSL)

Posted by Gary Tully <ga...@gmail.com>.
that needs an enhancement b/c the jndi context cannot create an ssl
factory at the moment.
do you really need jndi?

you may as well just instantiate ActiveMQSslConnectionFactory and
maybe just use jndi for the brokerURL

On 4 November 2013 10:49, mrich <ma...@qxlva.com> wrote:
> Hi,
>
> I am trying to create a secure ActiveMQ connection, using
> ActiveMQSslConnectionFactory that I want instantiated from JNDI.
>
> I have got JNDI working to lookup a standard ActiveMQ connection factory,
> however I am having problems updating this to create an
> ActiveMQSslConnectionFactory, whereby I can then programatically set
> keystore/truststore information.
>
>
> A sample of my code is:
>
> /Hashtable<String, String> environmentVariables = new Hashtable<String,
> String>();
> environmentVariables.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
> environmentVariables.put(Context.PROVIDER_URL, "ssl:/...");
>
> initialContext = new InitialContext(environmentVariables);
> QueueConnectionFactory connectionFactory =
> initialContext.lookup("QueueConnectionFactory");/
>
> This works fine, but I end up with a 'QueueConnectionFactory'. I can use the
> other 'lookup' options but that just gives me an ActiveMQConnectionFactory
> or the TopicConnectionFactory... but not the ActiveMQSslConnectionFactory
> that I require.
>
>
> Any guidance is appreciated.
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Instantiating-ActiveMQSslConnectionFactory-via-JNDI-SSL-tp4673824.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.



-- 
http://redhat.com
http://blog.garytully.com