Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to activate SSL(HTTPS) in Glassfish 3.0 embedded API?

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?

like image 261
Crazy Doc Avatar asked Mar 08 '10 12:03

Crazy Doc


1 Answers

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.

like image 87
Crazy Doc Avatar answered Oct 14 '22 02:10

Crazy Doc