我正在使用Java使用以下代码从网页中读取内容:
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();
}
}
当我在Windows pc上运行带有eclipse的代码时,它运行良好,但是当我尝试在树莓派上运行它时,出现此错误:
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
我认为这意味着Java不信任该网站,但是我在任何地方都找不到解决方案。任何帮助将不胜感激。