我想访问这个https://www.cityofathens.gr/khe/epixeiriseis/json?shop_id=49087页面使用java客户端来读取一些json数据。奇怪的是,当我在我的电脑上运行它,它工作得很好,但是当我运行jar到VM它给我这个错误SSLHandshakeException使用一台计算机,在另一个作品
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
我用这
String url="https://www.cityofathens.gr/khe/epixeiriseis/json?shop_id=49087";
BufferedReader in = new BufferedReader(new InputStreamReader(new URL(url).openStream()));
String result=IOUtils.toString(in);
System.out.println(result);
后一些挖掘我试图使用HttpsURLConnection
String url="https://www.cityofathens.gr/khe/epixeiriseis/json?shop_id=49087";
URL myurl = new URL(url);
HttpsURLConnection con = (HttpsURLConnection)myurl.openConnection();
InputStream ins = con.getInputStream();
InputStreamReader isr = new InputStreamReader(ins);
BufferedReader in = new BufferedReader(isr);
但错误保持不变!
有帮助吗? 谢谢
看起来像一个丢失的根证书 – Henry
@亨利,root作为Linux的根?客户端或服务器的?有趣的事情,尝试了它在我的旧电脑,并没有在那里工作(所有3使用Ubuntu) –