title: Plaintext Connection
body: <p>I am creating a simple HTTPS connection and returning a response</p>
  
  <pre><code>URL google = new URL("https://www.google.com/");
  HttpsURLConnection connection = (HttpsURLConnection)google.openConnection();
  System.out.println( "Response: " + connection.getResponseCode());
  </code></pre>
  
  <p>This works fine and I receive a 200 response (I have all the keystores and truststores etc. defined)</p>
  
  <p>I then proxy the request through a Jetty server by using https.proxyPort=8443 and https.proxyHost-localhost</p>
  
  <p>The server has connectors that look like this:</p>
  
  <pre><code>Server server = new Server();
  SelectChannelConnector connector0 = new SelectChannelConnector();
  connector0.setPort(8080);
  SslSelectChannelConnector sslConnector = new SslSelectChannelConnector();
  sslConnector.setPort(8443);
  SslContextFactory cf = sslConnector.getSslContextFactory();
  cf.setKeyStorePath(keyStoreHome);
  cf.setKeyStorePassword(keyStorePassword);
  cf.setTrustStore(trustStoreHome);
  cf.setTrustStorePassword(trustStorePassword);
  cf.setCertAlias("jetty");
  server.setConnectors(new Connector[] {connector0, sslConnector});
  server.setHandler(new HelloHandler());
  server.start();
  server.join();
  </code></pre>
  
  <p>Which gives me the error below:</p>
  
  <pre><code>DEBUG: org.eclipse.jetty.io.nio - created SCEP@33589e56{l(/127.0.0.1:62348)&lt;-&gt;r(/127.0.0.1:8443),d=false,open=true,ishut=false,oshut=false,rb=false,wb=false,w=true,i=0}-{SslConnection@7f033a6f SSL NOT_HANDSHAKING i/o/u=-1/-1/-1 ishut=false oshut=false {AsyncHttpConnection@26c623af,g=HttpGenerator{s=0,h=-1,b=-1,c=-1},p=HttpParser{s=-14,l=0,c=0},r=0}}
  DEBUG: org.eclipse.jetty.io.nio.ssl - [Session-1, SSL_NULL_WITH_NULL_NULL] SslConnection@7f033a6f SSL NOT_HANDSHAKING i/o/u=180/0/0 ishut=false oshut=false {AsyncHttpConnection@26c623af,g=HttpGenerator{s=0,h=-1,b=-1,c=-1},p=HttpParser{s=-14,l=0,c=0},r=0} NOT_HANDSHAKING filled=180/180 flushed=0/0
  DEBUG: org.eclipse.jetty.io.nio.ssl - SCEP@33589e56{l(/127.0.0.1:62348)&lt;-&gt;r(/127.0.0.1:8443),d=true,open=true,ishut=false,oshut=false,rb=false,wb=false,w=true,i=0r}-{SslConnection@7f033a6f SSL NEED_WRAP i/o/u=180/0/0 ishut=false oshut=false {AsyncHttpConnection@26c623af,g=HttpGenerator{s=0,h=-1,b=-1,c=-1},p=HttpParser{s=-14,l=0,c=0},r=0}}
  javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
  at com.sun.net.ssl.internal.ssl.EngineInputRecord.bytesInCompletePacket(EngineInputRecord.java:152)
  at com.sun.net.ssl.internal.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:806)
  at com.sun.net.ssl.internal.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:721)
  at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:607)
  at org.eclipse.jetty.io.nio.SslConnection.unwrap(SslConnection.java:519)
  at org.eclipse.jetty.io.nio.SslConnection.process(SslConnection.java:354)
  at org.eclipse.jetty.io.nio.SslConnection.access$900(SslConnection.java:43)
  at org.eclipse.jetty.io.nio.SslConnection$SslEndPoint.fill(SslConnection.java:661)
  at org.eclipse.jetty.http.HttpParser.fill(HttpParser.java:1030)
  at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:275)
  at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
  at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
  at org.eclipse.jetty.io.nio.SslConnection.handle(SslConnection.java:191)
  at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:620)
  at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
  at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
  at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
  at java.lang.Thread.run(Thread.java:662)
  DEBUG: org.eclipse.jetty.io.nio.ChannelEndPoint - close SCEP@33589e56{l(/127.0.0.1:62348)&lt;-&gt;r(/127.0.0.1:8443),d=true,open=true,ishut=false,oshut=false,rb=false,wb=false,w=true,i=0!}-{SslConnection@7f033a6f SSL NEED_WRAP i/o/u=180/0/0 ishut=false oshut=false {AsyncHttpConnection@26c623af,g=HttpGenerator{s=0,h=-1,b=-1,c=-1},p=HttpParser{s=-14,l=0,c=0},r=0}}
  DEBUG: org.eclipse.jetty.http.HttpParser - 
  
  javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
  </code></pre>
  
  <p>Can anybody please tell me what might be wrong with this?</p>