I am trying to access this https://www.cityofathens.gr/khe/epixeiriseis/json?shop_id=49087 page using a java client to read some json data. Strange thing is that when i run it on my computer it works just fine, but when i run the jar to a VM it is giving me 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 am using this
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);
After some digging I tried to use 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);
but the error remained the same!
any help? Thanks