glide - javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Could not find trust anchor for certificate path


Lalit Sharma

I migrated the server from HTTPto, HTTPSused a self-signed certificate to send network requests HttpUrlConnectionand it worked fine, but for the image loading it didn't work since I was already using Glide for the image loading.

javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Could not find trust anchor for certificate path. When loading image from https URL via glide library

Glide.with(mContext).load(currentItem.getImage_path().replace(" ", "%20"))
     .listener(new RequestListener<String, GlideDrawable>() {
        @Override
        public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
            genericViewHolder.imageView_1.setImageResource(R.drawable.image_thumbnail);
            genericViewHolder.progressBar.setVisibility(View.GONE);
            return false;
        }

        @Override
        public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
            genericViewHolder.progressBar.setVisibility(View.GONE);
            return false;
        }
    }).into(genericViewHolder.imageView_1);

I tried this link and used GlideModule but it doesn't seem to work. please help.

excited gosawi

The problem is related to the certificate, follow this link - https://stackoverflow.com/a/39032433/4741746

This will bypass the certificate and allow you to enter the system

See also this link - https://futurestud.io/tutorials/glide-module-example-accepting-self-signed-https-certificates

Create custom GlideModule class, OkHttpUrlLoader class and attach it to Glide as explained in above link

you have to put

<meta-data
        android:name="io.futurestud.tutorials.glide.glidemodule.CustomImageSizeGlideModule"
        android:value="GlideModule" />

Internal application tag for your AndroidMainifiedt file https://github.com/fs-opensource/android-tutorials-glide/blob/master/app/src/main/AndroidManifest.xml

Related