Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There's a simpler way to implement @jglouie 's solution. Basically, if you use a <code>SSLContext</code> and initialize it with <code>null</code> for the trust manager parameter, you should get a SSL context using the default trust manager. Note that this is not documented in the Android documentation, but the <a href="http://docs.oracle.com/javase/6/docs/api/javax/net/ssl/SSLContext.html#init%28javax.net.ssl.KeyManager%5B%5D,%20javax.net.ssl.TrustManager%5B%5D,%20java.security.SecureRandom%29" rel="noreferrer" title="Java documentation">Java documentation for SSLContext.init</a> says </p> <blockquote> <p>Either of the first two parameters may be null in which case the installed security providers will be searched for the highest priority implementation of the appropriate factory.</p> </blockquote> <p>Here's what the code would look like:</p> <pre><code>// This can be any protocol supported by your target devices. // For example "TLSv1.2" is supported by the latest versions of Android final String SSL_PROTOCOL = "TLS"; try { sslContext = SSLContext.getInstance(SSL_PROTOCOL); // Initialize the context with your key manager and the default trust manager // and randomness source sslContext.init(keyManagerFactory.getKeyManagers(), null, null); } catch (NoSuchAlgorithmException e) { Log.e(TAG, "Specified SSL protocol not supported! Protocol=" + SSL_PROTOCOL); e.printStackTrace(); } catch (KeyManagementException e) { Log.e(TAG, "Error setting up the SSL context!"); e.printStackTrace(); } // Get the socket factory socketFactory = sslContext.getSocketFactory(); </code></pre>
 

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