TLS 1.1 @ TLS 1.2 on httpclientandroidlib

During developing Android application I faced a problem with SSL connection in android lower than KIT KAT.

Application is using ch.boye.httpclientandroidlib to connect. When I tried to get httpConnection I'm getting error:

here was error during executing http request.

  javax.net.ssl.SSLPeerUnverifiedException: No peer certificate

In Android newest than KIT KAT everything works fine.

I'm trying to use solution sugested in here but i have a problem with casting types from ch.boye.httpclientandroidlib to apache elements in my current implemetations.

Is there any solution for using this library for android lower than KIT KAT?

Upvotes: 1

Views: 168

Answers (1)

RH201
RH201

Reputation: 321

I found a solution to this same issue here... using the class TlsSniSocketFactory (you'll have to also download IgnoreSSLTrustManager and SelfSignedTrustManager from the same "util" folder) and add it to your project. Then register the new scheme on your SchemeRegistry object like so:

schemeRegistry.register(new Scheme("https", new TlsSniSocketFactory(), port));

My issue was my web service is set to use TLS 1.2 only. Android devices running Android 4.4.4 and below do not automatically enable TLS 1.2 so you have to manually enable it (IMPORTANT * devices older than Android 4.1 cannot support TLS 1.2 at all, so this solution wont work for those older devices)

Late answer but hopefully helps someone

Cheers

Upvotes: 1

Related Questions