title: How to configure Jersey (javax.ws.rs.*) to reuse ssl sessions
body: <p>I have written a test client that sends requests over TLS using the Jersey library. I am having a hard time trying to figure out how to configure/code the Jersey client such that it reuses the SSL sessions so that I could make my tests faster. The Jersey client by default uses HTTP keepAlive; meaning it keeps the TCP connections open and reuses them, but it doesn't seem to do the same with SSL sessions.</p>
  
  <p>If anyone had any experience with this, please let me know.</p>
  
  <p>Here is the code snippet with which I am setting up the Jersey Client and also the code with which I am sending a request:</p>
  
  <pre><code>        SSLContext sslContext = sslConfig.createSSLContext().getInstance(tlsVersion);
          sslContext.init(keyManagerFactory.getKeyManagers(), trustAllCerts, new SecureRandom());
          SSLEngine sslEngine = sslContext.createSSLEngine("qa.p.uvvu.com", 7001);
  
          Client client =  ClientBuilder.newBuilder().sslContext(sslContext)
                  .hostnameVerifier(new HostnameVerifier() {
                      @Override
                      public boolean verify(String hostname, SSLSession session) {
                          return true;
                      }
                  }).build();
  
  
      response = client.target(uri).request()
              .headers(multivaluedMap).post(Entity.entity(object, MediaType.APPLICATION_XML_TYPE));
  </code></pre>