title: Cannot connect to https with HttpURLConnection
body: <p>I try to make a GET/POST to <code>http://www.android.com/</code> like in the example given in the <a href="https://developer.android.com/reference/java/net/HttpURLConnection.html" rel="nofollow noreferrer">documentation</a></p>
  
  <p>In the <code>InputStream</code> I get a message saying <code>302 Moved</code> and tells me to go on <code>https://www.android.com/</code></p>
  
  <p>When I modify my <code>URL</code> to https, I get:</p>
  
  <blockquote>
    <p>java.io.FileNotFoundException: <a href="https://www.android.com/" rel="nofollow noreferrer">https://www.android.com/</a></p>
  </blockquote>
  
  <pre><code>HttpsURLConnection con;
  String request = "https://www.android.com/";
  URL url = new URL(request);
      con = (HttpsURLConnection) url.openConnection();
      con.setDoOutput(true);
      con.setInstanceFollowRedirects(false);
      con.setRequestMethod("GET");
      con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
      con.setRequestProperty("charset", "utf-8");
      con.setRequestProperty("Content-Length", Integer.toString(postDataLength));
  </code></pre>
  
  <p><strong><em>Update</em></strong></p>
  
  <p>I thought it was an issue of SSL certificates, but it is not. I've added a function that will blindly trust all SSL certificates. Sources <a href="http://www.javased.com/index.php?api=javax.net.ssl.SSLSocketFactory" rel="nofollow noreferrer">here</a> and <a href="http://www.javased.com/index.php?source_dir=incubator-cordova-android/framework/src/org/apache/cordova/F" rel="nofollow noreferrer">here</a>.</p>