Page 1 of 1

javax.net.ssl.SSLHandshakeException: When coding on Pi

Posted: Tue Jan 29, 2019 3:40 pm
by Guyyyyy
Hello, I am using java to read from a webpage using this code:

Code: Select all

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, I get this error:

Code: Select all

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.

Re: javax.net.ssl.SSLHandshakeException: When coding on Pi

Posted: Thu Feb 07, 2019 12:01 am
by Guyyyyy
Updating java as described here fixed problem:
https://www.raspberrypi.org/forums/view ... p?t=200232