activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Reinhold <brianreinh...@lampreynetworks.com>
Subject How to configure embedded SSL broker using just Java code
Date Fri, 22 Nov 2013 17:11:55 GMT
This question was asked a while ago and the answers involved links and APIs
that no longer exist. I am unable to find any documentation to figure out
what classes correspond to what xml options, and if one is able to guess at
the classes, how to link them to the broker.

In the binary distributions an embedded example is given. It uses the Broker
class and not the BrokerService (as shown in the ActiveMQ FAQ). However, in
the context of an Apollo distribution, using the BrokerService as shown in
the ActiveMQ FAQ fails due to missing administrative classes.

In the example of the distribution, the Broker.setConfig(BrokerDTO) method
is used. 

The main method creates the embedded broker as follows:

        System.out.println("Starting the Broker.");
        broker = new Broker();
        broker.setConfig(createBrokerConfig());
        broker.start(new Runnable()
                    {
                        public void run()
                        {
                            System.out.println("The broker has now
started.");
                        }
                    });

calling the createBrokerConfig method which creates the BrokerDTO object:

    private static BrokerDTO createBrokerConfig()
    {
        BrokerDTO broker = new BrokerDTO();

        // Brokers support multiple virtual hosts.
        VirtualHostDTO host = new VirtualHostDTO();
        host.id = "localhost";
        host.host_names.add("localhost");
        host.host_names.add("127.0.0.1");

        // The message store is configured on the virtual host.
        LevelDBStoreDTO store = new LevelDBStoreDTO();
        store.directory = new File("./data");
        host.store = store;

        broker.virtual_hosts.add(host);

        //
        // Control which ports and protocols the broker binds and accepts
        AcceptingConnectorDTO connector = new AcceptingConnectorDTO();
        connector.id = "tcp";
        connector.bind = mqttServerUrl;

        broker.connectors.add(connector);

        //
        // Fires up the web admin console on HTTP.
        WebAdminDTO webadmin = new WebAdminDTO();
        webadmin.bind = "http://127.0.0.1:61680";
        broker.web_admins.add(webadmin);

        return broker;
    }

This simple code does create an unsecure broker.

I cannot for the life of me figure out how to place SSL configuration
information into the broker. I see this class:

        // From
http://activemq.apache.org/apollo/documentation/api/apollo-dto/index.html
        SslDTO sslDto = new SslDTO();
        sslDto.client_auth = "NEED";
        sslDto.version = "TLSv1";

but I have no idea how to link it to the BrokerDTO object. What I then
really need to do is to link the javax SslContextFactory to the
configuration info. But I have no idea how to do that.

I see some older posts that used the BrokerService class which used to have
an SslBrokerContext that could use the SslContextFactory but that class no
longer exists.

Though there is oodles of xml configuration information, there is almost no
documentation of information on using code to control/configure the embedded
option. Would really appreciate some help here!

Thanks,

Brian








--
View this message in context: http://activemq.2283324.n4.nabble.com/How-to-configure-embedded-SSL-broker-using-just-Java-code-tp4674768.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message