Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you really don't care about the validity of the server's certificate, then you want to set an <a href="http://java.sun.com/javase/6/docs/api/javax/net/ssl/SSLContext.html" rel="nofollow noreferrer"><code>SSLContext</code></a> that has a <a href="http://java.sun.com/javase/6/docs/api/javax/net/ssl/TrustManager.html" rel="nofollow noreferrer"><code>TrustManager</code></a> that doesn't check anything. Then you need to use that to set the default <a href="http://java.sun.com/javase/6/docs/api/javax/net/ssl/SSLSocketFactory.html" rel="nofollow noreferrer"><code>SSLSocketFactory</code></a> into the <a href="http://java.sun.com/javase/6/docs/api/java/net/HttpURLConnection.html" rel="nofollow noreferrer"><code>HttpsURLConnection</code></a>, so that the trust manager is used when you use the <a href="http://java.sun.com/javase/6/docs/api/java/net/URL.html" rel="nofollow noreferrer"><code>URL</code></a>. Here's an example:</p> <pre><code>TrustManager[] trustEverything = new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(X509Certificate[] certs, String authType) { } public void checkServerTrusted(X509Certificate[] certs, String authType) { } } }; SSLContext sslctx = SSLContext.getInstance("SSL"); sslctx.init(null, trustEverything, null); HttpsURLConnection.setDefaultSSLSocketFactory(sslctx.getSocketFactory()); </code></pre> <p>A full example using this technique can be found <a href="http://www.java-samples.com/showtutorial.php?tutorialid=211" rel="nofollow noreferrer">here</a>.</p> <p>As @erickson points out, this means that you can't tell if you're really talking to the server you're concerned about. An even better solution is to update your Trust store to include the self-signed certificate of the server you're talking to, instead of ignoring all checks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload