При отправке запроса вот сюда https://jsonplaceholder.typicode.com/posts/ вылетает исключение. Отправляю запрос с Android 5.1 Вот код:
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.i("fg", "onClick");
String URL = "https://jsonplaceholder.typicode.com/posts/" + editTextId.getText().toString();
client.post(URL, new RequestParams(), new JsonHttpResponseHandler(){
@Override
public void onSuccess(int statusCode, Header[] headers, JSONArray response) {
Log.i("fg", "response: " + response.toString());
}
@Override
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
Log.i("fg", "response: " + responseString);
}
});
}
});
}
А вот что выводит в логах:
javax.net.ssl.SSLHandshakeException: Handshake failed
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:405)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:535)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:403)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:472)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.conn.scheme.SchemeSocketFactoryAdaptor.connectSocket(SchemeSocketFactoryAdaptor.java:65)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:145)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:131)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:860)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at com.loopj.android.http.AsyncHttpRequest.makeRequest(AsyncHttpRequest.java:146)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at com.loopj.android.http.AsyncHttpRequest.makeRequestWithRetries(AsyncHttpRequest.java:177)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at com.loopj.android.http.AsyncHttpRequest.run(AsyncHttpRequest.java:106)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: at java.lang.Thread.run(Thread.java:818)
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x7f75d9c280: Failure in SSL library, usually a protocol error
10-05 22:43:01.391 2782-2895/com.colorblind.uncolor.cards W/System.err: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:770 0x7f76058888:0x00000000)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:323)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: ... 19 more
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: javax.net.ssl.SSLHandshakeException: Handshake failed
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:405)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:535)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:403)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:472)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.conn.scheme.SchemeSocketFactoryAdaptor.connectSocket(SchemeSocketFactoryAdaptor.java:65)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:145)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:131)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:860)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at com.loopj.android.http.AsyncHttpRequest.makeRequest(AsyncHttpRequest.java:146)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at com.loopj.android.http.AsyncHttpRequest.makeRequestWithRetries(AsyncHttpRequest.java:177)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at com.loopj.android.http.AsyncHttpRequest.run(AsyncHttpRequest.java:106)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
10-05 22:43:01.392 2782-2895/com.colorblind.uncolor.cards W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
10-05 22:43:01.393 2782-2895/com.colorblind.uncolor.cards W/System.err: at java.lang.Thread.run(Thread.java:818)
10-05 22:43:01.393 2782-2895/com.colorblind.uncolor.cards W/System.err: Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x7f75d9c280: Failure in SSL library, usually a protocol error
10-05 22:43:01.393 2782-2895/com.colorblind.uncolor.cards W/System.err: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:770 0x7f76058888:0x00000000)
10-05 22:43:01.393 2782-2895/com.colorblind.uncolor.cards W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
10-05 22:43:01.393 2782-2895/com.colorblind.uncolor.cards W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:323)
10-05 22:43:01.393 2782-2895/com.colorblind.uncolor.cards W/System.err: ... 19 more
10-05 22:43:01.394 2782-2782/com.colorblind.uncolor.cards W/JsonHttpRH: onFailure(int, Header[], Throwable, JSONObject) was not overriden, but callback was received
javax.net.ssl.SSLHandshakeException: Handshake failed
at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:405)
at cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:535)
at cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:403)
at cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:472)
at cz.msebera.android.httpclient.conn.scheme.SchemeSocketFactoryAdaptor.connectSocket(SchemeSocketFactoryAdaptor.java:65)
at cz.msebera.android.httpclient.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
at cz.msebera.android.httpclient.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:145)
at cz.msebera.android.httpclient.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:131)
at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
at cz.msebera.android.httpclient.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:860)
at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at com.loopj.android.http.AsyncHttpRequest.makeRequest(AsyncHttpRequest.java:146)
at com.loopj.android.http.AsyncHttpRequest.makeRequestWithRetries(AsyncHttpRequest.java:177)
at com.loopj.android.http.AsyncHttpRequest.run(AsyncHttpRequest.java:106)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x7f75d9c280: Failure in SSL library, usually a protocol error
error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:770 0x7f76058888:0x00000000)
at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:323)
... 19 more
Подскажите, пожалуйста, как решить данную проблему. Заранее благодарю за помощь!
Проблема заключается в SSLv3, по которому андроид подключается по дефолту. Даже если на сервере отключен SSLv3. После того, как SSLv3 стал компрометируемым, все больше серверов отключают этот протокол, оставляя только tls.
Попробуйте соединиться через openssl:
openssl s_client -connect site.com:443 -ssl3
скорее всего получите ошибку соединения. В то же время
openssl s_client -connect site.com:443 -tls1_2
вероятно соединится нормально (ну или -tls1
уж точно).
Чтобы решить проблему, необходимо удалить SSLv3 из доступных для связи протоколов для сокета. Делается это через оборачивание SSLSocket'а и переопределение setEnabledProtocols(String[] protocols)
с явным удалением из массива "SSLv3".
Добрый человек собрал проект с SSL фабрикой и выпиливанием SSLv3
https://github.com/gotev/okhttp-tlscompat
мне вот это помогло, поищи в эту сторону
ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
.tlsVersions(TlsVersion.TLS_1_2)
.cipherSuites(
CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
CipherSuite.TLS_DHE_RSA_WITH_AES_128_GCM_SHA256)
.build();
OkHttpClient client = new OkHttpClient.Builder()
.connectionSpecs(Collections.singletonList(spec))
.build();
Виртуальный выделенный сервер (VDS) становится отличным выбором
Я не могу понять, каким образом комбинировать регулярные выражения при использовании методаmatches
Я столкнулся с проблемой в правиле под названием "Due date for test1"Я передаю список tests в качестве параметра для того, чтобы проверить его на наличие...
Делаю игру пинг-понг на Java по книге Якова ФайнаКод состоит из двух классов и интерфейса (интерфейс игры, движок игры и константы)
Уважаемые товарищи, у меня просто ужас, а не ситуацияНе могу понять битый час в чём проблема, больше напоминает проблемы с софтом и/или компьютером