0

I am using java to read from a webpage using this code:

import java.net.*;
import java.io.*;

public class URLReader {
public static void main(String[] args)  throws Exception {

    URL oracle = new URL("http://www.example.com/");
    BufferedReader in = new BufferedReader(
    new InputStreamReader(oracle.openStream()));

    String inputLine;
    while ((inputLine = in.readLine()) != null)
        System.out.println(inputLine);
    in.close();
}
}

When I run the code with eclipse on my windows pc it works fine, but when I try to run it on my raspberry pi, I get this error:

javax.net.ssl.SSLHandshakeException:     sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid     certification path to requested target

I think it means java doesn’t trust the website, but I can’t find a solution anywhere. Any help would be greatly appreciated.

  • If the website uses https:// then does it have a valid publicly signed certificate or something that's self-signed? Is the root ca cert installed on your RPi? Is the server certificate trusted? Have you looked at Certbot to get a free (no charge) publicly valid certificate? – Dougie Feb 3 at 21:34
  • Sorry if this is a noob question, but how would I go about installing the root ca cert on my pi? – Bobjoesmith Feb 3 at 22:26
  • Your local Google must be broken. bounca.org/tutorials/install_root_certificate.html – Dougie Feb 4 at 10:13
0

I fixed the problem by updating java As described here:https://www.raspberrypi.org/forums/viewtopic.php?t=200232

  • We're looking for long answers that provide some explanation and context. Don't just give a one-line answer just with a link; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed or you risk to get down votes. – Ingo Feb 7 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.