Guyyyyy
Posts: 2
Joined: Tue Jan 29, 2019 3:32 pm

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

Tue Jan 29, 2019 3:40 pm

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.


Return to “Java”