1

I wrote a simple https servlet with Jetty according to the documentation which for some reason does not work. No error messages, nothing... the browser connects to the servlet, but that's it - after the connection it hangs forever. Here is the code:

    SslSocketConnector sslConnector =  new SslSocketConnector();
    sslConnector.setPort(5555);
    sslConnector.setKeystore(null);
    sslConnector.setHost("localhost");
    ((AbstractConnector) connector).setThreadPool(new QueuedThreadPool(20));
    server.addConnector (sslConnector);


ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");

    HandlerList handlers = new HandlerList();

    handlers.setHandlers(new Handler[] {context, new DefaultHandler() });
    server.setHandler(handlers);

    MyServlet servlet = new MyServlet();
    context.addServlet(new ServletHolder(servlet), "/*");

    server.start();
    server.join();       
0

1 Answer 1

1

sslConnector.setKeystore(null);

For an SSL connection you need to add a SSL certificate,which can be generated using tools provided in JDK.

See

http://download.oracle.com/javaee/1.4/tutorial/doc/Security6.html

2
  • From Jetty documentation: keystore - The resource path to the keystore, or null for built in keystores.
    – Demiurg
    Dec 11, 2010 at 8:25
  • Looks like it is a bug in Jetty documentation - it cannot be null after all, this "internal keystore", whatever that means, is either not working or does not exist
    – Demiurg
    Dec 25, 2010 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.