Hello Nick,

I tried again and it seems to work properly (see sample code in
attached file). However, as it seems that this connector is still a beta
release, the Restlet Jetty connector will use the Basic IO in SSL mode by 
default.

Best regards,
THierry Boileau

Hi Thierry, I wrote a simple tester in jetty6.1.1rc1 like this:
static void run(String keystore) {
        Server server = new Server();
                
        BlockingChannelConnector c = new BlockingChannelConnector();
        c.setPort(8181);
        server.addConnector(c);
                
        SslSelectChannelConnector c2 = new SslSelectChannelConnector();
        c2.setPort(8182);
                
        c2.setKeystore(keystore);
        c2.setKeyPassword("secret");
        c2.setPassword("secret");
                
        server.addConnector(c2);
                
        try {
                server.start();
        } catch (Exception e) {
                e.printStackTrace();
        }
}
When you use http to port 8182 you get the strange file response - and I found
out that this has to do with the TLS protocol handshake. It seems to be a
feature of java SSL. When you connect to 8181 with https, you get a 500 (I
think), but it has been handled - so it looks like a program error to us, but I
think its ok.

I was alarmed yesterday about what looked like bizare behaviour, I now think its
ok. Just a bit nervous about using a new framework perhaps. And by the way, I
really think restlets are great: great servlet replacement, and straightforward
code.

However, I think the above example uses the NIO SSL connector - the one that
does not seem to work in restlets. I think that these jetty connectors are very
recent.

Nick


        File keystoreFile = new File("<Path to keyStore file>");
        Component component = new org.restlet.Component();
        Application app = new Application(component.getContext()) {
            public Restlet createRoot() {
                Restlet restlet = new Restlet() {
                    @Override
                    public void handle(Request request, Response response) {
                        response
                                .setEntity("Hello World!", 
MediaType.TEXT_PLAIN);
                    }
                };
                return restlet;
            }
        };
  
        component.getContext().getParameters().add(new Parameter("type", "1"));
        component.getContext().getParameters().add(new 
Parameter("keystorePath", keystoreFile.toURI().toASCIIString()));
        component.getContext().getParameters().add(new 
Parameter("keystorePassword", "password"));
        component.getContext().getParameters().add(new Parameter("keyPassword", 
"password"));

        component.getServers().add(Protocol.HTTPS, 8181);
        component.getDefaultHost().attach("", app);
        component.start();

Reply via email to