Connecting to https gives: SSLHandshakeException Trust anchor for certification path not found
<p>Until now, i was connecting to a <code>http</code> server which returns some data. Now, that server has changed and its <code>https</code>. Now, when connecting to the new url I'm getting this exception:</p>

<pre><code>javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
</code></pre>

<p>In iOS this problem does not exist and the new https url returns the data correctly without doing nothing and with the same old code which worked with the <code>http</code> version of the server.</p>

<p>There is a way to avoid this problem without making changes at the source code like in iOS? This is only one of the various http connectiosn which i'm doing and which are being migrated to https on my app.</p>

<p>This is my code:</p>

<pre><code>URLConnection connection; 
URL url = new URL(configUrl);
connection = url.openConnection();
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);                
int responseCode = ((HttpURLConnection)connection).getResponseCode();
</code></pre>