Closed wussup closed 4 years ago
Workaround:
// FIX: Accept all certificates
{
try {
TrustManager[] trustAllCerts = new TrustManager[] {
new TrustAllManager()
};
// Install the all-trusting trust manager
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
} catch (NoSuchAlgorithmException | KeyManagementException e) {
e.printStackTrace();
}
// Install the all-trusting host verifier
HttpsURLConnection.setDefaultHostnameVerifier(new AllHostsValidVerifier());
}
private static class TrustAllManager implements X509TrustManager {
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
@Override
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
@Override
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
}
private static class AllHostsValidVerifier implements HostnameVerifier {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
}
Hello,
I am trying to load into the document image from https and get the next exception:
Could you please tell me, how I can trust all https certificates?