Retrofit OkHttp SSLHandshakeException

IgorGanapolsky

I am using OkHttp as the client in Retrofit. I am unable to hit a certain https url. This server supports TLS 1.0 only and the following ciphers TLS_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_RC4_128_MD5

Here's how I am instantiating my OkHttpClient:

    OkHttpClient client = new OkHttpClient();

    try {
        // Create a trust manager that does not validate certificate chains
        final TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
            @Override
            public void checkClientTrusted(
                    java.security.cert.X509Certificate[] chain,
                    String authType) throws CertificateException {
            }

            @Override
            public void checkServerTrusted(
                    java.security.cert.X509Certificate[] chain,
                    String authType) throws CertificateException {
            }

            @Override
            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                return null;
            }
        }};

        // Install the all-trusting trust manager
        final SSLContext sslContext = SSLContext.getInstance("TLSv1");
        sslContext.init(null, trustAllCerts, new java.security.SecureRandom());

        // Create an ssl socket factory with our all-trusting manager
        final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
        client.setSslSocketFactory(sslSocketFactory);

        client.setHostnameVerifier(new HostnameVerifier() {
            @Override
            public boolean verify(String hostname, SSLSession session) {
                return true;
            }
        });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }


    return client;
}

And my app keeps throwing this exception:

javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x9742f000: 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 0xab9fcc4d:0x00000000)

Barend

OkHttp no longer supports RC4 in its default config since OkHttp v2.3 (release notes). You can use the ConnectionSpec (javadoc) to enable it, the ConnectionSpecTest.java (source code) shows some examples.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

OkHttp + Picasso + Retrofit

From Dev

retrofit + okhttp : Retrieve GZIPInputStream

From Dev

Caching with OkHttp (without Retrofit)

From Dev

Retrofit and OkHttp gzip decode

From Dev

Using CookieHandler with OkHttp and Retrofit 2

From Dev

Retrofit 1.9 with OkHttp 2.2 and interceptors

From Dev

Retrofit + OkHTTP - response cache not working

From Dev

OkHttp + Retrofit offline cache not working

From Dev

OkHttp + Retrofit offline cache not working

From Dev

Offline cache okhttp + retrofit not working

From Dev

Retrofit detected an unsupported OkHttp on the classpath error in OKHttp 2.0

From Dev

Retrofit detected an unsupported OkHttp on the classpath error in OKHttp 2.0

From Dev

unable to set retrofit timeout along with picasso and okhttp

From Java

why use Retrofit when we have OkHttp

From Dev

Retrofit 2/OkHttp: Cancel all running requests

From Dev

Is Retrofit+Okhttp using httpCaching as a default in Android?

From Java

Comparison of Android networking libraries: OkHTTP, Retrofit, and Volley

From Java

How to retry HTTP requests with OkHttp/Retrofit?

From Dev

Retrofit + OkHttp + GZIP-ed JSON

From Dev

Retrofit - Okhttp client How to cache the response

From Dev

Using @PUT with Retrofit 2 and OkHttp3

From Dev

why use Retrofit when we have OkHttp

From Dev

Difference in ThreadPoolExecutor usage in OkHttp and Retrofit for async operations

From Dev

Okhttp ignores Dispatcher setting when used with Retrofit RxJavaCallAdapterFactory

From Java

Can Retrofit with OKHttp use cache data when offline

From Dev

Consuming One-Shot ResponseBody from Okhttp causes issues with Retrofit

From Dev

Unsupported operation: Android, Retrofit, OkHttp. Adding interceptor in OkHttpClient

From Dev

How to invalidate/force update of cache route at next request with Retrofit and OKHttp?

From Dev

How Retrofit with OKHttp use cache data when offline

Related Related

  1. 1

    OkHttp + Picasso + Retrofit

  2. 2

    retrofit + okhttp : Retrieve GZIPInputStream

  3. 3

    Caching with OkHttp (without Retrofit)

  4. 4

    Retrofit and OkHttp gzip decode

  5. 5

    Using CookieHandler with OkHttp and Retrofit 2

  6. 6

    Retrofit 1.9 with OkHttp 2.2 and interceptors

  7. 7

    Retrofit + OkHTTP - response cache not working

  8. 8

    OkHttp + Retrofit offline cache not working

  9. 9

    OkHttp + Retrofit offline cache not working

  10. 10

    Offline cache okhttp + retrofit not working

  11. 11

    Retrofit detected an unsupported OkHttp on the classpath error in OKHttp 2.0

  12. 12

    Retrofit detected an unsupported OkHttp on the classpath error in OKHttp 2.0

  13. 13

    unable to set retrofit timeout along with picasso and okhttp

  14. 14

    why use Retrofit when we have OkHttp

  15. 15

    Retrofit 2/OkHttp: Cancel all running requests

  16. 16

    Is Retrofit+Okhttp using httpCaching as a default in Android?

  17. 17

    Comparison of Android networking libraries: OkHTTP, Retrofit, and Volley

  18. 18

    How to retry HTTP requests with OkHttp/Retrofit?

  19. 19

    Retrofit + OkHttp + GZIP-ed JSON

  20. 20

    Retrofit - Okhttp client How to cache the response

  21. 21

    Using @PUT with Retrofit 2 and OkHttp3

  22. 22

    why use Retrofit when we have OkHttp

  23. 23

    Difference in ThreadPoolExecutor usage in OkHttp and Retrofit for async operations

  24. 24

    Okhttp ignores Dispatcher setting when used with Retrofit RxJavaCallAdapterFactory

  25. 25

    Can Retrofit with OKHttp use cache data when offline

  26. 26

    Consuming One-Shot ResponseBody from Okhttp causes issues with Retrofit

  27. 27

    Unsupported operation: Android, Retrofit, OkHttp. Adding interceptor in OkHttpClient

  28. 28

    How to invalidate/force update of cache route at next request with Retrofit and OKHttp?

  29. 29

    How Retrofit with OKHttp use cache data when offline

HotTag

Archive