title: How to set “jsse.enableSNIExtension” to false only for a single HTTPURLConnection?
body: <p>I currently have an application that would make HTTP post request to a lot of URLs. Some of the connections are failing with the following exception.</p>
  
  <blockquote>
    <p>Exception in thread "main" javax.net.ssl.SSLProtocolException:
    handshake alert:  unrecognized_name   at
    sun.security.ssl.ClientHandshaker.handshakeAlert(ClientHandshaker.java:1410)
      at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2004)
      at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1113)
      at
    sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1363)
      at
    sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1391)</p>
    
    <p>. . .</p>
  </blockquote>
  
  <p>Hence, I want to set “jsse.enableSNIExtension” to false only for specific connections which throw the above mentioned exception.</p>
  
  <p>How do I do it on an HTTPsURLConnection/SSLSocket level?</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>URL url = new URL("https://artofskinmd.localgiftcards.com/");
  HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
  
  httpConnection.connect();
  </code></pre>
  
  <p>I am trying to find a way to change the SSLParameters for the HttpsURLConnection object. But I am unable to find any setSSLParameters() method for setting an empty server names list. I am not able to find anything online on setting SSLParameters for HttpURLConnection, SSLContext etc</p>