title: Programmatically and temporarily disable SNI check in JAX-RS client with sun.net.**.HttpsClient
body: <p>I'm getting the old <code>HTTP transport error: javax.net.ssl.SSLProtocolException: handshake alert: unrecognized_name</code> error on service where I need to disable SNI handshake because reasons. I do NOT want to do it globally with <code>System.setProperty("jsse.enableSNIExtension", "false");</code> as suggested elsewhere and the http binding uses <code>sun.net.www.protocol.https.HttpsClient</code> and I can't seem to change that. I have tried approaches like <a href="https://erikwramner.wordpress.com/2013/03/27/trust-self-signed-ssl-certificates-and-skip-host-name-verification-with-jax-ws/" rel="nofollow">https://erikwramner.wordpress.com/2013/03/27/trust-self-signed-ssl-certificates-and-skip-host-name-verification-with-jax-ws/</a></p>
  
  <p>where I have set custom SSLSocketFactories and HostnameVerifiers like so:</p>
  
  <pre><code> BindingProvider bp = (BindingProvider) webServicePort;
              Map requestContext = bp.getRequestContext();
              requestContext.put("com.sun.xml.internal.ws.transport.https.client.SSLSocketFactory", getTrustingSSLSocketFactory());
              requestContext.put("com.sun.xml.ws.transport.https.client.SSLSocketFactory", getTrustingSSLSocketFactory());
              final NaiveHostnameVerifier naiveHostnameVerifier = new NaiveHostnameVerifier();
              requestContext.put("com.sun.xml.internal.ws.transport.https.client.hostname.verifier", naiveHostnameVerifier);
              requestContext.put("com.sun.xml.ws.transport.https.client.hostname.verifier", naiveHostnameVerifier);
  </code></pre>
  
  <p>This simply has no effect since the http client doesn't seem to honour these properties.</p>
  
  <p>Any tips appreciated!</p>