我遇到了小米米5s Plus的问题。 Android 7.0
当我尝试连接到“https://www.skelbiu.lt”时出现此错误:
12-08 09:58:41.725 15226-15264/dk.pawliux.app.dbasearch W/System.err: javax.net.ssl.SSLHandshakeException: Handshake failed
12-08 09:58:41.727 15226-15264/dk.pawliux.app.dbasearch W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:429)
12-08 09:58:41.727 15226-15264/dk.pawliux.app.dbasearch W/System.err: at com.squareup.okhttp.Connection.connectTls(Connection.java:235)
12-08 09:58:41.727 15226-15264/dk.pawliux.app.dbasearch W/System.err: at com.squareup.okhttp.Connection.connectSocket(Connection.java:199)
12-08 09:58:41.728 15226-15264/dk.pawliux.app.dbasearch W/System.err: at com.squareup.okhttp.Connection.connect(Connection.java:172)
12-08 09:58:41.728 15226-15264/dk.pawliux.app.dbasearch W/System.err: at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:367)
12-08 09:58:41.728 15226-15264/dk.pawliux.app.dbasearch W/System.err: at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
12-08 09:58:41.728 15226-15264/dk.pawliux.app.dbasearch W/System.err: at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
12-08 09:58:41.729 15226-15264/dk.pawliux.app.dbasearch W/System.err: at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:245)
12-08 09:58:41.729 15226-15264/dk.pawliux.app.dbasearch W/System.err: at com.squareup.okhttp.Call.getResponse(Call.java:267)
12-08 09:58:41.729 15226-15264/dk.pawliux.app.dbasearch W/System.err: at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:224)
12-08 09:58:41.729 15226-15264/dk.pawliux.app.dbasearch W/System.err: at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:195)
12-08 09:58:41.730 15226-15264/dk.pawliux.app.dbasearch W/System.err: at com.squareup.okhttp.Call.execute(Call.java:79)
12-08 09:58:41.730 15226-15264/dk.pawliux.app.dbasearch W/System.err: at dk.pawliux.app.dbasearch.tasks.SearchSkelbiuTask.doInBackground(SearchSkelbiuTask.java:115)
12-08 09:58:41.730 15226-15264/dk.pawliux.app.dbasearch W/System.err: at dk.pawliux.app.dbasearch.tasks.SearchSkelbiuTask.doInBackground(SearchSkelbiuTask.java:31)
12-08 09:58:41.731 15226-15264/dk.pawliux.app.dbasearch W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:304)
12-08 09:58:41.732 15226-15264/dk.pawliux.app.dbasearch W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
12-08 09:58:41.732 15226-15264/dk.pawliux.app.dbasearch W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
12-08 09:58:41.732 15226-15264/dk.pawliux.app.dbasearch W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
12-08 09:58:41.733 15226-15264/dk.pawliux.app.dbasearch W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
12-08 09:58:41.733 15226-15264/dk.pawliux.app.dbasearch W/System.err: at java.lang.Thread.run(Thread.java:760)
12-08 09:58:41.734 15226-15264/dk.pawliux.app.dbasearch W/System.err: Suppressed: javax.net.ssl.SSLHandshakeException: Handshake failed
12-08 09:58:41.735 15226-15264/dk.pawliux.app.dbasearch W/System.err: ... 20 more
12-08 09:58:41.736 15226-15264/dk.pawliux.app.dbasearch W/System.err: Caused by: javax.net.ssl.SSLProtocolException: SSL handshake terminated: ssl=0x7f91e82c00: Failure in SSL library, usually a protocol error
12-08 09:58:41.737 15226-15264/dk.pawliux.app.dbasearch W/System.err: error:10000410:SSL routines:OPENSSL_internal:SSLV3_ALERT_HANDSHAKE_FAILURE (external/boringssl/src/ssl/s3_pkt.c:610 0x7f742434c0:0x00000001)
12-08 09:58:41.737 15226-15264/dk.pawliux.app.dbasearch W/System.err: error:1000009a:SSL routines:OPENSSL_internal:HANDSHAKE_FAILURE_ON_CLIENT_HELLO (external/boringssl/src/ssl/s3_clnt.c:764 0x7f8505df76:0x00000000)
12-08 09:58:41.737 15226-15264/dk.pawliux.app.dbasearch W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
12-08 09:58:41.737 15226-15264/dk.pawliux.app.dbasearch W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:357)
12-08 09:58:41.738 15226-15264/dk.pawliux.app.dbasearch W/System.err: ... 19 more
12-08 09:58:41.740 15226-15264/dk.pawliux.app.dbasearch W/System.err: Caused by: javax.net.ssl.SSLProtocolException: SSL handshake terminated: ssl=0x7f91e82c00: Failure in SSL library, usually a protocol error
12-08 09:58:41.741 15226-15264/dk.pawliux.app.dbasearch W/System.err: error:1000043e:SSL routines:OPENSSL_internal:TLSV1_ALERT_INAPPROPRIATE_FALLBACK (external/boringssl/src/ssl/s3_pkt.c:610 0x7f742434c0:0x00000001)
12-08 09:58:41.745 15226-15264/dk.pawliux.app.dbasearch W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
12-08 09:58:41.745 15226-15264/dk.pawliux.app.dbasearch W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:357)
12-08 09:58:41.745 15226-15264/dk.pawliux.app.dbasearch W/System.err: ... 19 more
我尝试了许多不同的方式连接到网络:JSoup,HttpsUrlConnection,OkHttp
使用OkHttp我摆脱了部分问题。连接代码现在看起来像这样:
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(url).build();
ConnectionSpec specTLS1_2 = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
.cipherSuites(new CipherSuite[]{CipherSuite.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, CipherSuite.TLS_DHE_DSS_WITH_AES_128_CBC_SHA}).build();
ConnectionSpec specTLSAll = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS).build();
ArrayList specs = new ArrayList<>();
specs.add(specTLS1_2);
specs.add(specTLSAll);
client.setConnectionSpecs(specs);
Response response = client.newCall(request).execute();
从此处获取的连接代码:javax.net.ssl.SSLHandshakeException: Handshake failed
我现在遇到的失败是:
12-08 10:12:32.011 16205-16255/dk.pawliux.app.dbasearch W/System.err: Caused by: javax.net.ssl.SSLProtocolException: SSL handshake terminated: ssl=0x7f91e82180: Failure in SSL library, usually a protocol error
12-08 10:12:32.012 16205-16255/dk.pawliux.app.dbasearch W/System.err: error:10000410:SSL routines:OPENSSL_internal:SSLV3_ALERT_HANDSHAKE_FAILURE (external/boringssl/src/ssl/s3_pkt.c:610 0x7f751a67c0:0x00000001)
12-08 10:12:32.012 16205-16255/dk.pawliux.app.dbasearch W/System.err: error:1000009a:SSL routines:OPENSSL_internal:HANDSHAKE_FAILURE_ON_CLIENT_HELLO (external/boringssl/src/ssl/s3_clnt.c:764 0x7f8505df76:0x00000000)
12-08 10:12:32.012 16205-16255/dk.pawliux.app.dbasearch W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
12-08 10:12:32.013 16205-16255/dk.pawliux.app.dbasearch W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:357)
12-08 10:12:32.013 16205-16255/dk.pawliux.app.dbasearch W/System.err: ... 19 more
12-08 10:12:32.014 16205-16255/dk.pawliux.app.dbasearch W/System.err: Caused by: javax.net.ssl.SSLProtocolException: SSL handshake terminated: ssl=0x7f91e82180: Failure in SSL library, usually a protocol error
12-08 10:12:32.014 16205-16255/dk.pawliux.app.dbasearch W/System.err: error:10000410:SSL routines:OPENSSL_internal:SSLV3_ALERT_HANDSHAKE_FAILURE (external/boringssl/src/ssl/s3_pkt.c:610 0x7f751a67c0:0x00000001)
12-08 10:12:32.014 16205-16255/dk.pawliux.app.dbasearch W/System.err: error:1000009a:SSL routines:OPENSSL_internal:HANDSHAKE_FAILURE_ON_CLIENT_HELLO (external/boringssl/src/ssl/s3_clnt.c:764 0x7f8505df76:0x00000000)
12-08 10:12:32.014 16205-16255/dk.pawliux.app.dbasearch W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
12-08 10:12:32.015 16205-16255/dk.pawliux.app.dbasearch W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:357)
12-08 10:12:32.015 16205-16255/dk.pawliux.app.dbasearch W/System.err: ... 19 more
看起来我摆脱了TLSV1_ALERT_INAPPROPRIATE_FALLBACK
警告错误,但仍然出现SSLV3_ALERT_HANDSHAKE_FAILURE
错误。
注意到Chrome等浏览器对该网站没有任何问题。包括虚拟仿真器在内的其他智能手机也运行良好。
我根据这些信息使用了CipherSuite协议: