On Mon, 2014-07-28 at 10:44 +0200, Marius Shekow wrote: > Hi, > > there is an official port on > http://hc.apache.org/httpcomponents-client-4.3.x/android-port.html > > You "forgot" to give usage instructions for it, as it seems. What needs > to be done for this to work? For example, is it enough to just place the > jar file in the libs dir, and it will automatically use the new 4.3 code > base when using "... = new DefaultHttpClient()" ? Or do I need to > instantiate it the "new way", i.e. using "HttpClients.createDefault()" ? > > In that regard, I'm also wondering how to teach the Http-client a custom > certificate chain, given that I'm using a Root CA which isn't known to > all Android devices by default. So far I was able to do that using > Android's old HttpClient implementation, by creating a new > SchemeRegistry and registering a SSLSocketFactory which accepts a > KeyStore reference. > > So far I have some code and I believe it is correct, but you're not > providing any examples and there also aren't any on the net: > > CloseableHttpClient testClient = null; > SSLContextBuilder builder = new SSLContextBuilder(); > KeyStore trusted; > try { > trusted = KeyStore.getInstance("BKS"); > InputStream in = > MainActivity.this.getResources().openRawResource(R.raw.mykeystorefileWithCertificates); > try { > trusted.load(in, "mobile360".toCharArray()); > } finally { > in.close(); > } > builder.loadTrustMaterial(trusted); > SSLContext sslContext = builder.build(); > SSLConnectionSocketFactory test = new > SSLConnectionSocketFactory(sslContext); > testClient = > HttpClientBuilder.create().setSSLSocketFactory(test).build(); > } catch (Exception e) { > e.printStackTrace(); > } >
I see nothing wrong with your code. > Maybe some tutorials are in order? Absolutely. HC is a community driven project, so happily take contributions. Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
