Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Many thanks to Nikolay Elenkov!</p> <p>Finally, I found the solution. I follow this link: <a href="http://nelenkov.blogspot.com/2011/12/using-custom-certificate-trust-store-on.html" rel="nofollow">Using a Custom Certificate Trust Store on Android</a></p> <p>First, I use <code>DefaultHttpClient</code> instead of <code>HttpClient</code> (the method <code>createHttpClientWithDefaultSocketFactory()</code> should be <code>return DefaultHttpClient</code>):</p> <pre><code>private DefaultHttpClient createHttpClientWithDefaultSocketFactory( KeyStore keyStore, KeyStore trustStore) { try { SSLSocketFactory sslSocketFactory = SSLSocketFactory .getSocketFactory(); if (keyStore != null &amp;&amp; trustStore != null) { sslSocketFactory = new SSLSocketFactory(keyStore, KEYSTORE_PASSWORD, trustStore); } else if (trustStore != null) { sslSocketFactory = new SSLSocketFactory(trustStore); } return createHttpClient(sslSocketFactory); } catch (GeneralSecurityException e) { throw new RuntimeException(e); } } </code></pre> <p>Then I add <code>CredentialsProvider</code> for authentication.</p> <pre><code> DefaultHttpClient client = createHttpClientWithDefaultSocketFactory( keyStore, trustStore); HttpPost httpPost = new HttpPost(SERVER_AUTH_URL); httpPost.setHeader("Content-type", "text/xml;utf-8"); StringEntity se = new StringEntity(builder.toString(), "UTF8"); se.setContentType("text/xml"); httpPost.setEntity(se); CredentialsProvider credProvider = new BasicCredentialsProvider(); credProvider.setCredentials(new AuthScope(URL, 443), new UsernamePasswordCredentials(USERNAME, password)); // This will exclude the NTLM authentication scheme client.setCredentialsProvider(credProvider); HttpResponse response = client.execute(httpPost); </code></pre> <p>Now, it can work well!</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