Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSL Handshake fails connecting to Google from Android client

Tags:

java

android

ssl

I'm using the standard piece of code

URL url = new URL(sb.toString());
conn = (HttpsURLConnection) url.openConnection();
InputStreamReader in = new InputStreamReader(conn.getInputStream());

to connect to the Google Places API from an Android client. However I get this exception:

02-24 02:29:35.535: E/AdapterClass(3122):   at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:374)
02-24 02:29:35.535: E/AdapterClass(3122):   at com.android.okhttp.Connection.upgradeToTls(Connection.java:197)
02-24 02:29:35.535: E/AdapterClass(3122): Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xaf85c200: Failure in SSL library, usually a protocol error
02-24 02:29:35.535: E/AdapterClass(3122): error:1407743E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert inappropriate fallback (external/openssl/ssl/s23_clnt.c:765 0xac3f9e61:0x00000000)

Any ideas? I noticed this only happens when I use OkHttp for requests, but not for this particular request but in other parts of my app. So why would okhttp play a role here (as shown in the stacktrace)?

like image 723
splinter123 Avatar asked Nov 10 '22 18:11

splinter123


1 Answers

This problem gets solved by switching to the latest version (2.2 as of now) of OkHttp (I was using 1.6 before).

like image 185
splinter123 Avatar answered Nov 14 '22 22:11

splinter123