How can I configure an osgi http whiteboard servlet for HTTPS?

1.1k Views Asked by At

I have built a REST interface via the http whiteboard servlet pattern in osgi

@Component(service = RestComponentImpl.class)
@JaxrsResource
@HttpWhiteboardResource(pattern = "/rest/*", prefix = "static")
public class RestComponentImpl {  

    @Path("test")
    @PUT
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    public TestObject getTest(TestObject testo) {
        return testo;
    }
}

I configured jetty for HTTPS via osgi configuration passed as json on startup

{
  "org.apache.felix.http": {
    "org.apache.felix.http.enable": "true",
    "org.apache.felix.https.enable": "true",
    "org.osgi.service.http.port.secure": "8443",
    "org.apache.felix.https.keystore": "src/main/resources/jetty_key/keystore",
    "org.apache.felix.https.keystore.password": "mostsecurepasswordever",
  }
}

my bndrun looks like

index: target/index.xml;name="rest-app"

-standalone: ${index}

-runrequires: 
osgi.identity;filter:='(osgi.identity=resttest.rest-services)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.metatype)',\
osgi.identity;filter:='(osgi.identity=org.apache.johnzon.core)',\

-runfw: org.eclipse.osgi
-runee: JavaSE-1.8
-runbundles: \
    ch.qos.logback.classic;version='[1.2.3,1.2.4)',\
    ch.qos.logback.core;version='[1.2.3,1.2.4)',\
    org.apache.aries.javax.jax.rs-api;version='[1.0.0,1.0.1)',\
    org.apache.aries.jax.rs.whiteboard;version='[1.0.0,1.0.1)',\
    org.apache.felix.configadmin;version='[1.9.2,1.9.3)',\
    org.apache.felix.http.jetty;version='[4.0.0,4.0.1)',\
    org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
    org.apache.felix.scr;version='[2.1.0,2.1.1)',\
    org.apache.servicemix.specs.annotation-api-1.3;version='[1.3.0,1.3.1)',\
    org.osgi.service.jaxrs;version='[1.0.0,1.0.1)',\
    org.osgi.util.function;version='[1.1.0,1.1.1)',\
    org.osgi.util.promise;version='[1.1.0,1.1.1)',\
    slf4j.api;version='[1.7.25,1.7.26)',\
    org.apache.servicemix.specs.json-api-1.1;version='[2.9.0,2.9.1)',\
    org.osgi.util.converter;version='[1.0.0,1.0.1)',\
    org.apache.felix.metatype;version='[1.2.0,1.2.1)',\
    resttest.rest-app;version='[0.0.1,0.0.2)',\
    org.apache.felix.configurator;version='[1.0.0,1.0.1)',\
    org.apache.johnzon.core;version='[1.1.0,1.1.1)'

Without the https configuration provided above, the servlet works flawlessly via http://localhost:8080/test With the configuration I still have access to the static content, like index.html which is residing in static, via https://localhost:8443/rest/index.html With the https configuration the service doesn't even start:

Component #0 resttest.rest.RestComponentImpl, state satisfied

And I can't connect to https://localhost:8443/test, getting:

HTTP ERROR 404
Problem accessing /test. Reason:
Not Found

The Apache Felix Web Console works flawless under both configurations via http://localhost:8080/system/console/ or https://localhost:8443/system/console/

Anyone an idea or suggestion? Or any other ideas, to quickly build a REST-solution deployed in an osgi-context with json serialization, without hassling with a bigger framework? Thanks.

0

There are 0 best solutions below