ade_ari_w0 0 Newbie Poster

How to read file from https post with certificate.
This is my code

public static void postHttp(String Linknya) throws MalformedURLException, IOException {
File source=new File(path+"hasilnya.csv");
if (!source.isFile())
{
source.createNewFile();
}
source.setWritable(true);
if (source.canWrite())
{
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
URL url = new URL(Linknya);
URLConnection urlc = url.openConnection();
bis = new BufferedInputStream(urlc.getInputStream());
bos = new BufferedOutputStream(new FileOutputStream(source));
int i;
while ((i = bis.read()) != -1) {
bos.write(i);
}
} finally {
if (bis != null) try { bis.close(); } catch (IOException ioe) { }
else
System.out.println(" Please Check Connection ");
if (bos != null) try { bos.close(); } catch (IOException ioe) { }
}
}

}

to use that function like this for example
postHttp("www.google.com");

when i use that function for web which has certificate i get this error

sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target


please help me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.