I've tryed this method to establish a secure connection to the server of my university. In a small java application it works for me, but not under Android 2.3.3. Instead, I get the following exception:
javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException:
Trust anchor for certification path not found.`
- Where is the problem with this solution? Is it the truststore itself or I have imported the "wrong" certificate?
- How can I debug such errors better?
My code:
try {
File dir = Environment.getExternalStorageDirectory();
File file = new File(dir, "test.jks");
if (file.exists()) {
System.out.println(file.getAbsolutePath());
System.setProperty("javax.net.ssl.trustStore", file.getAbsolutePath());
System.setProperty("javax.net.ssl.trustStorePassword", "myPassword");
System.out.println(System.getProperty("javax.net.ssl.trustStore"));
Document document = Jsoup.connect("https://www.dhbw-loerrach.de/").get();
lblMessage.setText(document.html());
}
} catch (Exception ex) {
System.out.println(ex.getMessage());
}