Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Glide - javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found

I migrated the server from HTTP to HTTPS I have used self-signed certificate to send network requests with HttpUrlConnection and it worked but for image loading it is not working as I have used Glide for Image loading.

javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.while loading images from https URL through 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 using this link and used GlideModule but it does not seem to work. Please help.

like image 425
Lalit Sharma Avatar asked Dec 13 '16 06:12

Lalit Sharma


People also ask

What does trust anchor for certification path not found mean?

Trust anchor for certification path not found. That error is usually due to a misconfigured certificate or a misconfiguration with the webserver config files as it relates to certificates…

What is javax net SSL Sslhandshakeexception?

Indicates that the client and server could not negotiate the desired level of security. The connection is no longer usable.


1 Answers

The issue is about certificate follow this link -https://stackoverflow.com/a/39032433/4741746

This will bypass certificate and allow you to enter in system

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

Create your custom GlideModule Class,OkHttpUrlLoader class and attach to you Glide as mention in above link

You have to put

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

Inside application tag of your AndroidMainifiest file https://github.com/fs-opensource/android-tutorials-glide/blob/master/app/src/main/AndroidManifest.xml

like image 74
sushant gosavi Avatar answered Oct 16 '22 15:10

sushant gosavi