改造HTTP失败:javax.net.ssl.SSLHandshakeException

时间:2018-09-02 07:40:50

标签: android retrofit sslhandshakeexception

我在我的应用程序中使用Retrofit进行联网。应用程序在OS版本大于4.4的设备上运行良好,但在OS版本4.4(API 19)的模拟器中抛出javax.net.ssl.SSLHandshakeException。这是我的改造配置

    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.BODY);
    final OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .readTimeout(180, TimeUnit.SECONDS)
                .connectTimeout(180, TimeUnit.SECONDS)
                .addInterceptor(logging)
                .build();

    final Retrofit retrofit = new Retrofit.Builder().baseUrl(BuildConfig.BASE_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .client(okHttpClient)
            .build();

    mListener = retrofit.create(ApiListener.class);

这是我的异常日志

D/OkHttp: <-- HTTP FAILED: javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb8c1d320: 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:741 0x8d9bf990:0x00000000)

我添加了具有TLS版本TLS_1_2的连接spce。现在我得到java.net.UnknownServiceException: Unable to find acceptable protocols

0 个答案:

没有答案