title: How to handle https url that ends up plaintext connection
body: <p>I try to get the page content of a https url that throws an exception while getting input stream.</p>
  
  <pre><code>String httpsURL = "https://careers.virtusa.com/";
  URL myurl = new URL(httpsURL);
  HttpsURLConnection con = (HttpsURLConnection)myurl.openConnection();
  InputStream ins = con.getInputStream();
  </code></pre>
  
  <p>The exception is as below,</p>
  
  <pre><code>Exception in thread "main" javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
      at com.sun.net.ssl.internal.ssl.InputRecord.handleUnknownRecord(InputRecord.java:523)
      at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:355)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:798)
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1138)    
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1165)    
      at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1149)    
      at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:434)    
      at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1172)    
      at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)      
      at url.JavaHttpsExample.main(JavaHttpsExample.java:18)    
  </code></pre>
  
  <p>Both <code>HttpURLConnection</code> and <code>HttpsURLConnection</code> fail. I tried <code>org.apache.http.impl.client.CloseableHttpClient</code> but getting the same exception. In browser it works fine.</p>