title: Jetty SSL not working. Accessing website gives unreadable output
body: <p>EDIT: Self-signed certificate installed on browser made it work.</p>
  
  <p>I have configured jetty 9 embedded for http on port 8080 and https on port 8443. When I visit localhost:8080 I get my website and everything works, but when I try to access localhost:8443, I get this mess: <a href="http://i.stack.imgur.com/AGx0F.png" rel="nofollow">image of unreadable stuff</a>.</p>
  
  <p>I pretty much mimicked the <a href="http://download.eclipse.org/jetty/stable-9/xref/org/eclipse/jetty/embedded/ManyConnectors.html" rel="nofollow">ManyConnectorsExample</a> in the jetty documentation in order to set up a http connector and a https connector. Here is my code:</p>
  
  <pre><code>File keystoreFile = new File("config/myownkeystore.p12");
      if (!keystoreFile.exists()){
          throw new FileNotFoundException(keystoreFile.getAbsolutePath());
      }
  
      Server server = new Server();
  
      HttpConfiguration http_config = new HttpConfiguration();
      http_config.setSecureScheme("https");
      http_config.setSecurePort(8443);
      http_config.setOutputBufferSize(32768);
  
      ServerConnector http = new ServerConnector(server,
              new HttpConnectionFactory(http_config));
      http.setPort(8080);
      http.setIdleTimeout(30000);
  
      SslContextFactory sslContextFactory = new SslContextFactory();
      sslContextFactory.setKeyStoreType("PKCS12");
      sslContextFactory.setKeyStorePath(keystoreFile.getAbsolutePath());
      sslContextFactory.setKeyStorePassword("myownstorepass");
      sslContextFactory.setKeyManagerPassword("myownkeypass");
  
  
      HttpConfiguration https_config = new HttpConfiguration(http_config);
      SecureRequestCustomizer src = new SecureRequestCustomizer();
      src.setStsMaxAge(2000);
      src.setStsIncludeSubDomains(true);
      https_config.addCustomizer(src);
  
      ServerConnector https = new ServerConnector(server,
          new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
              new HttpConnectionFactory(https_config));
      https.setPort(8443);
      https.setIdleTimeout(500000);
  
      // Set the connectors
      server.setConnectors(new Connector[] { http, https });
  
      // servlet handler
      ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
      servletContextHandler.setResourceBase(".");
      servletContextHandler.setContextPath("/");
      servletContextHandler.addServlet(new ServletHolder(new MainServlet()), "/*");
  
      // set the handlers
      HandlerCollection handlerList = new HandlerCollection();
      handlerList.setHandlers(new Handler[]{servletContextHandler});
      server.setHandler(handlerList);
  </code></pre>
  
  <p>At first I thought that maybe the keystore type was at fault, since jetty uses jks by default. So I switched the sslcontext to use pkcs12 since the keystore is a .p12 file. That didn't help.</p>
  
  <p>I checked the passwords next but the password for both private key and for the keystore are the same, so that can't be the issue. </p>
  
  <p>At this point, I want to believe its a fault in my code somewhere, but I don't know what is wrong exactly.</p>