Retrofit2 doesn't work in android 4 with https

-1

I use retrofit2 in my app. that's work properly in android >= 5 but in android 4 it does not work. If I use "http" in BASE_URL it works. note : my ssl is Self-signed and free ssl.

public class APIClient {
private static Retrofit retrofit = null;
private static final String BASE_URL = "https://test.com/api/";

public static Retrofit getClient(){
    if(retrofit == null) {
        retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }
    return retrofit;
}}

I tried some ways but it didn't work. logcat :

mytag: Failure 
javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x2b9c40: Failure in SSL library, usually a protocol error
error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version (external/openssl/ssl/s23_clnt.c:658 0x4028fcc3:0x00000000)
    at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:460)
    at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:257)
android
retrofit2
asked on Stack Overflow Nov 3, 2018 by PCcamp.Ir • edited Nov 4, 2018 by PCcamp.Ir

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0