0

I am downloading html source code of this webpage https://tv.zam.it/ch-Rai-1 using this:

    String content= "";
    URLConnection connection = null;
    try {
        URL url = new URL(address[0]);
        connection = (URLConnection) url.openConnection();
        Scanner scanner = new Scanner(connection.getInputStream());
        scanner.useDelimiter("\\Z");
        while (scanner.hasNext()) content += scanner.next();
        scanner.close();
    } catch (Exception ex) {
        content = ex.toString();
    }
  • on 2019 samsung phone with android 9 works fine
  • on fire tv stick (Fire OS 5.2.8.0) works fine
  • on w95 android tv box (android 7.1.2) it returns this message:

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

I tried many of the suggested solutions but I could not make any of them change a thing. The webpage just provides tv shows info and I just need to fetch some strings from the sources, no fancy things or strict security checks required. Any suggestion?

kekk0
  • 47
  • 7

2 Answers2

1

Add your certificate(s) to a custom trust manager like described in this post: Trusting all certificates using HttpClient over HTTPS

Here are some more solution https://stackoverflow.com/a/16302527/9959901

Nakul Bharti
  • 113
  • 9
0

Turns out the dns server that was added to the failing device doesn't like that site. This was the cause of the issue. Switching to another dns fixed the issue without change to the app.

kekk0
  • 47
  • 7