You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Paul F Fraser <pa...@a2zliving.com> on 2016/04/13 03:38:36 UTC
Using config admin to setup https
Hi,
I have used the code below to try and set up https. Using org.apache.felix.http.jetty version 3.2.0
Webconsole shows I have 2 services running, one containing the default settings for jetty and one
containing my setting as per my code.
As a result, Jetty starts up on port 8080.
Presumably the http bundle starts and creates the default version.
How do I replace the default service?
Thanks,
Paul Fraser
@Component
public class JettyConfig {
@Reference
ConfigurationAdmin configAdmin;
private Configuration config;
private Path keystorePath;
@Activate
public void startup(ComponentContext ctx) throws IOException {
Dictionary<String, Object> props = new Hashtable();
String pid = "org.apache.felix.http";
props.put("org.apache.felix.http.enable", false);
props.put("org.apache.felix.https.enable", true);
props.put("org.osgi.service.http.port.secure", 8443);
props.put("org.apache.felix.https.keystore", keystorePath.toString());
props.put("org.apache.felix.https.keystore.password", "keypass");
config = configAdmin.createFactoryConfiguration(pid, null);
config.update(props);
}
@Deactivate
public void shutdown() throws IOException {
config.delete();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Using config admin to setup https
Posted by Paul F Fraser <pa...@a2zliving.com>.
On 14/04/2016 5:11 AM, Karel Haeck wrote:
>
> Paul,
>
> any reason why you are using a factory configuration ?
> replacing config = configAdmin.createFactoryConfiguration(pid, null);
> with config = configAdmin.getConfiguration(pid, null);
> should work.
>
Hi Karel,
Thanks, the problem was as you suggested. I looked but did not see ;-)
Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Using config admin to setup https
Posted by Karel Haeck <ka...@telenet.be>.
Paul,
any reason why you are using a factory configuration ?
replacing config = configAdmin.createFactoryConfiguration(pid, null);
with config = configAdmin.getConfiguration(pid, null);
should work.
On 13/04/2016 3:38, Paul F Fraser wrote:
> Hi,
>
> I have used the code below to try and set up https. Using
> org.apache.felix.http.jetty version 3.2.0
>
> Webconsole shows I have 2 services running, one containing the default
> settings for jetty and one containing my setting as per my code.
>
> As a result, Jetty starts up on port 8080.
>
> Presumably the http bundle starts and creates the default version.
> How do I replace the default service?
>
> Thanks,
>
> Paul Fraser
>
> @Component
> public class JettyConfig {
>
> @Reference
> ConfigurationAdmin configAdmin;
> private Configuration config;
> private Path keystorePath;
>
> @Activate
> public void startup(ComponentContext ctx) throws IOException {
>
> Dictionary<String, Object> props = new Hashtable();
>
> String pid = "org.apache.felix.http";
>
> props.put("org.apache.felix.http.enable", false);
> props.put("org.apache.felix.https.enable", true);
> props.put("org.osgi.service.http.port.secure", 8443);
> props.put("org.apache.felix.https.keystore",
> keystorePath.toString());
> props.put("org.apache.felix.https.keystore.password", "keypass");
>
> config = configAdmin.createFactoryConfiguration(pid, null);
> config.update(props);
> }
>
> @Deactivate
> public void shutdown() throws IOException {
> config.delete();
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org