title: Trust Websocket SSL - Getting fatal alert: handshake_failure
body: <p>I've been researching why I'm getting:</p>
  
  <pre><code>java.util.concurrent.ExecutionException: javax.net.ssl.SSLException: Received fatal alert: handshake_failure
  </code></pre>
  
  <p>but I've come up at a loss. Here is my code:</p>
  
  <pre><code>import org.eclipse.jetty.util.log.Log;
  import org.eclipse.jetty.util.log.Logger;
  import org.eclipse.jetty.util.ssl.SslContextFactory;
  import org.eclipse.jetty.websocket.api.Session;
  import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
  import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
  import org.eclipse.jetty.websocket.api.annotations.OnWebSocketError;
  import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
  import org.eclipse.jetty.websocket.api.annotations.WebSocket;
  import org.eclipse.jetty.websocket.client.WebSocketClient;
  
  import java.net.URI;
  import java.security.NoSuchAlgorithmException;
  import java.util.concurrent.Future;
  
  @WebSocket
  public class ConnectDamnit {
  
      private static final Logger LOG = Log.getLogger(ConnectDamnit.class);
  
      public static void main(String[] args) throws NoSuchAlgorithmException
      {
          String url = "wss://host.com:10443/listen";
  
          SslContextFactory sslContextFactory = new SslContextFactory();
          sslContextFactory.setTrustAll(true); // The magic
  
          WebSocketClient client = new WebSocketClient(sslContextFactory);
          try
          {
              client.start();
              ConnectDamnit socket = new ConnectDamnit();
              Future&lt;Session&gt; fut = client.connect(socket,URI.create(url));
              Session session = fut.get();
              session.getRemote().sendString("{JSONDATA}");
          }
          catch (Throwable t)
          {
              LOG.warn(t);
              t.printStackTrace(System.err);
          }
      }
  
      @OnWebSocketConnect
      public void onConnect(Session sess)
      {
          LOG.info("onConnect({})",sess);
      }
  
      @OnWebSocketClose
      public void onClose(int statusCode, String reason)
      {
          LOG.info("onClose({}, {})", statusCode, reason);
      }
  
      @OnWebSocketError
      public void onError(Throwable cause)
      {
          LOG.warn(cause);
      }
  
      @OnWebSocketMessage
      public void onMessage(String msg)
      {
          LOG.info("onMessage() - {}", msg);
      }
  }
  </code></pre>
  
  <p>And here is the full error:</p>
  
  <pre><code>java.util.concurrent.ExecutionException: javax.net.ssl.SSLException: Received fatal alert: handshake_failure
      at org.eclipse.jetty.util.FuturePromise.get(FuturePromise.java:123)
      at JMeter.plugins.functional.samplers.websocket.ConnectDamnit.main(ConnectDamnit.java:40)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
  Caused by: javax.net.ssl.SSLException: Received fatal alert: handshake_failure
      at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
      at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1666)
      at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1634)
      at sun.security.ssl.SSLEngineImpl.recvAlert(SSLEngineImpl.java:1800)
      at sun.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:1083)
      at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:907)
      at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:781)
      at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
      at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.fill(SslConnection.java:502)
      at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.flush(SslConnection.java:802)
      at org.eclipse.jetty.io.WriteFlusher.completeWrite(WriteFlusher.java:400)
      at org.eclipse.jetty.io.ssl.SslConnection$1.run(SslConnection.java:97)
      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607)
      at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>I'm able to connect to this socket using a chrome plugin just fine so I'm not sure why I can't here. Any pointers or suggestions? I can connect to wss://echo.websocket.org/ just fine</p>