Glide V4 load https images
Asked Answered
J

2

6

I know this link, and tried but this is for Glide V3 solution, I need to load https://myimage/image/xxx.png but glide throw exception

FileNotFoundException(No content provider)** and **SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found

I am using 4.5.0 Glide version, I have spend a lot of time but can't find any solution, any help will be appreciated.

Jeroldjeroma answered 29/3, 2018 at 13:15 Comment(1)
This exception means that your myimage server has a self-signed cert, not a publically signed one. The below answers explain how to tell glide to ignore this. Another option is to properly set up https, for example by installing let's encrypt on your web server or hosting the images on S3 or another well-configured environment..Foucquet
S
3

Structure of the answer of Mohit works fine, however right now you can take all the required classes here So to include them just add

implementation "com.github.bumptech.glide:okhttp3-integration:$glideV"
Scriabin answered 30/7, 2018 at 9:39 Comment(0)
A
0

This solution work form me with implementation 'com.github.bumptech.glide:glide:4.8.0'

Add in extends Application

SSLContext mySSLContext = SSLContext.getInstance("TLS");
TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new java.security.cert.X509Certificate[]{};
}

public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}

public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
}};
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String arg0, SSLSession arg1) {
if (arg0.equalsIgnoreCase("YOUR_DOMAIN OR YOUR IP"))
return true;
else
return false;
}
});
Aesthete answered 15/1, 2019 at 4:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.