SSLHandshakeException при получении данных из TheMovieDataBase с помощью Retrofit + OkHttp в Android - PullRequest
1 голос
/ 16 мая 2019

Я пытаюсь получить список фильмов из TheMovieDatabase (TMDb)

Получить: https://api.themoviedb.org/3/movie/now_playing?api_key=${KEY}&page=1

Однако я получаю следующее:

HTTP FAILED: javax.net.ssl.SSLHandshakeException: соединение закрыто равный

Ниже приведен код, который я уже пробовал:

 if (okHttpClient == null) {

            ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.COMPATIBLE_TLS) //tried MODERN_TLS also
                    .tlsVersions(TlsVersion.TLS_1_2)
                    .supportsTlsExtensions(true)                       
                    .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 = new OkHttpClient.Builder()
                    .connectionSpecs(Collections.singletonList(spec))
                    .connectTimeout(30, TimeUnit.SECONDS)
                    .readTimeout(30, TimeUnit.SECONDS)
                    .addInterceptor(logging)
                    .build();
        }

        if (retrofit == null)
            retrofit = new Retrofit.Builder()
                    .baseUrl(APIUtils.BASE_URL)
                    .client(okHttpClient)
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .addConverterFactory(GsonConverterFactory.create())
                    .build();
        return retrofit;
    }

Логи:

javax.net.ssl.SSLHandshakeException: соединение закрыто узлом на com.android.org.conscrypt.NativeCrypto.SSL_do_handshake (собственный метод) на com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake (OpenSSLSocketImpl.java:324) на okhttp3.internal.connection.RealConnection.connectTls (RealConnection.java:318) по адресу okhttp3.internal.connection.RealConnection.establishProtocol (RealConnection.java:282) на okhttp3.internal.connection.RealConnection.connect (RealConnection.java:167) в okhttp3.internal.connection.StreamAllocation.findConnection (StreamAllocation.java:257) в okhttp3.internal.connection.StreamAllocation.findHealthyConnection (StreamAllocation.java:135) на okhttp3.internal.connection.StreamAllocation.newStream (StreamAllocation.java:114) по адресу okhttp3.internal.connection.ConnectInterceptor.intercept (ConnectInterceptor.java:42) в okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:147) в okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:121) на okhttp3.internal.cache.CacheInterceptor.intercept (CacheInterceptor.java:93) в okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:147) в okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:121) по адресу okhttp3.internal.http.BridgeInterceptor.intercept (BridgeInterceptor.java:93) в okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:147) на okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept (RetryAndFollowUpInterceptor.java:126) в okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:147) в okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:121) на okhttp3.logging.HttpLoggingInterceptor.intercept (HttpLoggingInterceptor.java:213) в okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:147) в okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:121) в okhttp3.RealCall.getResponseWithInterceptorChain (RealCall.java:200) на okhttp3.RealCall.execute (RealCall.java:77) на com.google.firebase.perf.network.FirebasePerfOkHttpClient.execute (Неизвестно Источник) в retrofit2.OkHttpCall.execute (OkHttpCall.java:180) в retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual (CallExecuteObservable.java:42) на io.reactivex.Observable.subscribe (Observable.java:12030) в retrofit2.adapter.rxjava2.BodyObservable.subscribeActual (BodyObservable.java:34) на io.reactivex.Observable.subscribe (Observable.java:12030) в io.reactivex.internal.operators.observable.ObservableObserveOn.subscribeActual (ObservableObserveOn.java:45) на io.reactivex.Observable.subscribe (Observable.java:12030) в io.reactivex.internal.operators.observable.ObservableSubscribeOn $ SubscribeTask.run (ObservableSubscribeOn.java:96) в io.reactivex.Scheduler $ DisposeTask.run (Scheduler.java:579) в io.reactivex.internal.schedulers.ScheduledRunnable.run (ScheduledRunnable.java:66) в io.reactivex.internal.schedulers.ScheduledRunnable.call (ScheduledRunnable.java:57) в java.util.concurrent.FutureTask.run (FutureTask.java:237) в java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.run (ScheduledThreadPoolExecutor.java:269)в java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1113) в java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:588) в java.lang.Thread.run (поток)

...