简体   繁体   English

SSL握手无法从Android客户端连接到Google

[英]SSL Handshake fails connecting to Google from Android client

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. 从Android客户端连接到Google Places API。 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. 我注意到这只发生在我使用OkHttp请求时,但不是针对此特定请求,而是在我的应用程序的其他部分。 So why would okhttp play a role here (as shown in the stacktrace)? 那么为什么okhttp会在这里发挥作用(如堆栈跟踪中所示)?

这个问题通过切换到OkHttp的最新版本(现在为2.2)得到解决(之前我使用的是1.6)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM