Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Trust anchor for certification path not found. The exception occurs on a real device but not on the emulator

I have an android app that connects to HelioHost. My app runs fine on the emulator (API 33) but when I run it on a real device (API 22) I get the following exception:

javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

Here is the code that produces the exception:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

protected String doInBackground(String... strings) {
            String username = strings[0];
            String activationKey = strings[1];
            InputStream inStream = null;
            String response = null;
            
            try {
                ContentValues values=new ContentValues();
                values.put("username", username);
                values.put("activationKey", activationKey);
                URL url = new URL("https://zelda82.heliohost.org/activation.php");
                HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
                conn.setRequestMethod("POST");
                conn.setDoInput(true);
                conn.setDoOutput(true);

                OutputStream os = conn.getOutputStream();
                BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));

                writer.write(getQuery(values));
                writer.flush();
                writer.close();
                os.close();

                BufferedReader reader = new BufferedReader(new InputStreamReader((conn.getInputStream())));
                response = reader.readLine();
                reader.close();
            }

            catch(Exception e) {
                e.printStackTrace();
            }

            return response;
        }

I didn’t have this problem before them doing a maintenance. Is it possible that there is a server misconfiguration?

>Solution :

when I run it on a real device (API 22) I get the following exception

That device is about 10 years old. Only around 1% of Android devices in use are that old.

The operators of that Web site do not expect anyone to use an Android device that is that old. They use Let’s Encrypt for a free SSL certificate, and Let’s Encrypt only supports Android 7.0 and higher.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading