bumptech / glide

An image loading and caching library for Android focused on smooth scrolling
https://bumptech.github.io/glide/
Other
34.66k stars 6.12k forks source link

NASA'S HTTPS Images do not load on Pre-Lollipop Devices - SSLHandshakeException #1679

Closed JeffreyCA closed 7 years ago

JeffreyCA commented 7 years ago

Glide Version: 3.7.0

Integration libraries:

Default - fails OkHttp/3 - fails load failed: javax.net.ssl.SSLHandshakeException Volley - fails java.util.concurrent.ExecutionException: com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException

Device/Android Version: Fails on devices running 4.4 and lower. I've only tested on Android emulators, I unfortunately do not have a physical device running 4.4 or lower.

Issue details / Repro steps / Use case background: This problem seems to occur on images hosted on the nasa domain only (HTTPS). They recently moved everything from HTTP to HTTPS. It loads on Android versions greater than 5.0.

E.g., https://apod.nasa.gov/apod/image/1701/ic4406_hubble_960.jpg

For instance, this HTTPS image from Wikipedia loads perfectly using Glide: https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg

Glide load line / GlideModule (if any) / list Adapter code (if any):

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        try {
            ImageView view = (ImageView) findViewById(R.id.image);
            String url = "https://apod.nasa.gov/apod/image/1701/IC443HubblePalette2_8x10flat4bColes1024.jpg";
            Glide.with(this).load(url).into(view);
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }

Layout XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="jeffrey.ca.test.MainActivity">

    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true" />
</RelativeLayout>

Stack trace / LogCat:

OkHttp v2

01-08 12:59:22.213 3588-3588/jeffrey.ca.test D/GenericRequest: load failed
  javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb8cc55f0: 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:741 0x988d9990:0x00000000)
  at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:448)
  at com.squareup.okhttp.Connection.upgradeToTls(Connection.java:241)
  at com.squareup.okhttp.Connection.connect(Connection.java:158)
  at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:174)
  at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:120)
  at com.squareup.okhttp.internal.http.RouteSelector.next(RouteSelector.java:131)
  at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:312)
  at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:235)
  at com.squareup.okhttp.Call.getResponse(Call.java:262)
  at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:219)
  at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:192)
  at com.squareup.okhttp.Call.execute(Call.java:79)
  at com.bumptech.glide.integration.okhttp.OkHttpStreamFetcher.loadData(OkHttpStreamFetcher.java:42)
  at com.bumptech.glide.integration.okhttp.OkHttpStreamFetcher.loadData(OkHttpStreamFetcher.java:19)
  at com.bumptech.glide.load.model.ImageVideoModelLoader$ImageVideoFetcher.loadData(ImageVideoModelLoader.java:70)
  at com.bumptech.glide.load.model.ImageVideoModelLoader$ImageVideoFetcher.loadData(ImageVideoModelLoader.java:53)
  at com.bumptech.glide.load.engine.DecodeJob.decodeSource(DecodeJob.java:170)
  at com.bumptech.glide.load.engine.DecodeJob.decodeFromSource(DecodeJob.java:128)
  at com.bumptech.glide.load.engine.EngineRunnable.decodeFromSource(EngineRunnable.java:122)
  at com.bumptech.glide.load.engine.EngineRunnable.decode(EngineRunnable.java:101)
  at com.bumptech.glide.load.engine.EngineRunnable.run(EngineRunnable.java:58)
  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:841)
  at com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor$DefaultThreadFactory$1.run(FifoPriorityThreadPoolExecutor.java:118)
  Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb8cc55f0: 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:741 0x988d9990:0x00000000)
  at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
  at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:405)
    ... 26 more

OkHttp3 v3.5.0

01-08 13:07:53.373 11228-11228/jeffrey.ca.test D/GenericRequest: load failed
  javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb8cc6ab0: 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:741 0x988d9990:0x00000000)
  at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:448)
  at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:242)
  at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:200)
  at okhttp3.internal.connection.RealConnection.buildConnection(RealConnection.java:174)
  at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:114)
  at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:196)
  at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:132)
  at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:101)
  at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
  at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
  at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
  at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
  at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:179)
  at okhttp3.RealCall.execute(RealCall.java:63)
  at com.bumptech.glide.integration.okhttp3.OkHttpStreamFetcher.loadData(OkHttpStreamFetcher.java:43)
  at com.bumptech.glide.integration.okhttp3.OkHttpStreamFetcher.loadData(OkHttpStreamFetcher.java:19)
  at com.bumptech.glide.load.model.ImageVideoModelLoader$ImageVideoFetcher.loadData(ImageVideoModelLoader.java:70)
  at com.bumptech.glide.load.model.ImageVideoModelLoader$ImageVideoFetcher.loadData(ImageVideoModelLoader.java:53)
  at com.bumptech.glide.load.engine.DecodeJob.decodeSource(DecodeJob.java:170)
  at com.bumptech.glide.load.engine.DecodeJob.decodeFromSource(DecodeJob.java:128)
  at com.bumptech.glide.load.engine.EngineRunnable.decodeFromSource(EngineRunnable.java:122)
  at com.bumptech.glide.load.engine.EngineRunnable.decode(EngineRunnable.java:101)
  at com.bumptech.glide.load.engine.EngineRunnable.run(EngineRunnable.java:58)
  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:841)
  at com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor$DefaultThreadFactory$1.run(FifoPriorityThreadPoolExecutor.java:118)
  Suppressed: javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb8c80110: 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:741 0x988d9990:0x00000000)
  ... 36 more
  Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb8c80110: 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:741 0x988d9990:0x00000000) at com.android.org.conscrypt.Nat

I've tried many workarounds posted on StackOverflow, none seem to work. I also tried this guide, which does not work either.

SivasoeDev commented 7 years ago

Same issue for me too. Cannot find a work around. UnsafeOkHttpGlideModule also don't work. Please help.

SivasoeDev commented 7 years ago

Hi JeffreyCA, try the following link below. I solved my issue by using it. https://github.com/square/okhttp/issues/2372

I have just modified my UnsafeOkHttpClient, as needed, by using the code in that link. It worked for me.