我将服务器从 HTTP
迁移到 HTTPS
我使用自签名证书通过 HttpUrlConnection
发送网络请求并且它有效但是对于图像加载它不起作用,因为我使用 Glide 进行图像加载。
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);
我尝试使用 this链接并使用了 GlideModule 但它似乎不起作用。请帮忙。
最佳答案
问题与证书有关,请点击此链接 - https://stackoverflow.com/a/39032433/4741746
这将绕过证书并允许您进入系统
另请参阅此链接 - https://futurestud.io/tutorials/glide-module-example-accepting-self-signed-https-certificates
创建您的自定义 GlideModule 类,OkHttpUrlLoader 类并附加到您的 Glide,如上面链接中所述
你必须把
<meta-data
android:name="io.futurestud.tutorials.glide.glidemodule.CustomImageSizeGlideModule"
android:value="GlideModule" />
AndroidMainifiest 文件的内部应用程序标签 https://github.com/fs-opensource/android-tutorials-glide/blob/master/app/src/main/AndroidManifest.xml
关于android - Glide - javax.net.ssl.SSLHandshakeException : java. security.cert.CertPathValidatorException:找不到证书路径的信任 anchor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41114569/