title: Jetty http2 client to ignore self-signed cert
body: <p>I have an http2 server at <a href="https://ec2-52-57-54-142.eu-central-1.compute.amazonaws.com/" rel="nofollow">https://ec2-52-57-54-142.eu-central-1.compute.amazonaws.com/</a> with a self-signed cert. And I have a jetty http2 client that simply posts things to it. For some reason, I'm not getting ignoring self-signed cert to work. Here's a snippet of relevant code</p>
  
  <pre><code>SslContextFactory factory = new SslContextFactory(true);
  factory.setTrustAll(true);
  factory.setValidateCerts(false);
  factory.setValidatePeerCerts(false);
  factory.setEndpointIdentificationAlgorithm(null);
  
  SSLContext sslContext = factory.getSslContext();
  if(null == sslContext) {
      sslContext = SSLContext.getInstance("TLS");
  }
  TrustManager[] verifiers = new TrustManager[] {...// some dummy trust manager that always passes};
  sslContext.init(null, verifiers, null);
  factory.setSslContext(sslContext);
  
  HttpClientTransportOverHTTP2 httpClientTransportOverHTTP2
              = new HttpClientTransportOverHTTP2(new HTTP2Client());
  HttpClient httpClient = new HttpClient(httpClientTransportOverHTTP2, factory);
  
  
  Request request = httpClient.POST(destination);
  ContentProvider contentProvider = new InputStreamContentProvider(new StringInputStream(payload));
  request.content(contentProvider);
  ContentResponse response = request.send();
  </code></pre>
  
  <p>And I get these stacktrace</p>
  
  <pre><code>Caused by: java.util.concurrent.ExecutionException: java.nio.channels.ClosedChannelException
      at org.eclipse.jetty.client.util.FutureResponseListener.getResult(FutureResponseListener.java:118)
      at org.eclipse.jetty.client.util.FutureResponseListener.get(FutureResponseListener.java:101)
      at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:652)
      at my code
      ... 34 more
  Caused by: java.nio.channels.ClosedChannelException
      at org.eclipse.jetty.io.WriteFlusher.onClose(WriteFlusher.java:498)
      at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onIncompleteFlush(SslConnection.java:409)
      at org.eclipse.jetty.io.AbstractEndPoint$2.onIncompleteFlush(AbstractEndPoint.java:54)
      at org.eclipse.jetty.io.WriteFlusher.write(WriteFlusher.java:322)
      at org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:140)
      at org.eclipse.jetty.http2.HTTP2Flusher.process(HTTP2Flusher.java:243)
      at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:241)
      at org.eclipse.jetty.util.IteratingCallback.succeeded(IteratingCallback.java:365)
      at org.eclipse.jetty.http2.HTTP2Flusher.succeeded(HTTP2Flusher.java:258)
      at org.eclipse.jetty.io.WriteFlusher$PendingState.complete(WriteFlusher.java:269)
      at org.eclipse.jetty.io.WriteFlusher.completeWrite(WriteFlusher.java:394)
      at org.eclipse.jetty.io.ssl.SslConnection$1.run(SslConnection.java:101)
      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
      at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
      ... 1 more
  </code></pre>
  
  <p>When I step through things with a debugger, I see something about NOT_HANDSHAKE in one of the connection objects.</p>
  
  <p>I really don't care about verifying anything. I just want to connect over HTTP2/TLS. I searched for many different terms, but they all end up with more or less the same thing (setTrustAll, custom TrustManager, etc)</p>
  
  <p>Any help? Thanks!</p>
  
  <p>P.S. Jetty version 9.3.12</p>