开发者

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

开发者 https://www.devze.com 2022-12-22 10:26 出处:网络
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 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 开发者_StackOverflow社区configuration to activate SSL for the port.

Has anyone experience in configuring embedded Glassfish with SSL?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消