Mohit Suthar
Mohit Suthar

Reputation: 9395

Glide V4 load https images

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.

Upvotes: 6

Views: 12697

Answers (2)

Nam Nguyen Thanh
Nam Nguyen Thanh

Reputation: 1

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;
}
});

Upvotes: 0

Nazacheres
Nazacheres

Reputation: 99

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"

Upvotes: 3

Related Questions