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.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Mohit Suthar
  • 8,725
  • 10
  • 37
  • 67
  • 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.. – Barett Jul 12 '19 at 02:11

2 Answers2

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"
Nazacheres
  • 99
  • 10
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;
}
});