views:

383

answers:

2

We are implementing an application with a webservice as component and decided to use the Glassfish 3.0 embedded distri to provide the webservice. And it works.

We need a SSL(HTTPS) connection to the webservice, but we didn't find any documentation or hint how to activate it programmatically via the embedded API.

Thus we tried to configure the embedded Glassfish via domain.xml, what has a listener configured with SSL. And the port is reachable but only without SSL. The embedded Glassfish seem to ignore the configuration to activate SSL for the port.

Has anyone experience in configuring embedded Glassfish with SSL?

A: 

Google's first hit for "glassfish ssl v3"

http://blogs.sun.com/theaquarium/entry/using_ssl_in_glassfish

Will
The question is about GlassFish **embedded** API (i.e. starting GlassFish programmatically).
Pascal Thivent
That's right Pascal. We need to do it programmatically.
Crazy Doc
A: 

Ok, sorry that it took so much time for my answer.

The programmatical embedded API seems not to porvide a way to do this task. Except to run an asadmin command:

logger.debug("Configure port for SSL");
        String command = "create-http-listener";
        ParameterMap params = new ParameterMap();
        params.add("listeneraddress", "0.0.0.0");
        params.add("listenerport", "443");
        params.add("defaultvs", "server");
        params.add("securityenabled", "true");
        params.add("enabled", "true");
        params.add("DEFAULT", "http-listener2");
        CommandRunner runner = server.getHabitat().getComponent(CommandRunner.class);
        ActionReport report = server.getHabitat().getComponent(ActionReport.class);
        runner.getCommandInvocation(command, report).parameters(params).execute();

Running this code is simmlar to execute:

asadmin create-http-listener --listeneraddress 0.0.0.0 --listenerport 443 --defaultvs server securityenabled=true --enabled=true http-listener2

But this solution creates a new port with SSL. Reconfigure the already started port would be a nice option.

Crazy Doc