I want to read content of https URL entered by user that we have not any data about certificate key and jks and etc:
<!DOCTYPE html>
<html>
<head>
<title>Total Synthesis of Fidaxomicin | | download</title>
</head>
<body>
<form action="testSSL.jsp">
<input name="sslRandomUrl" type="text">
<input type="submit" value="opensslUrl" >
</form>
</body>
and this is jsp :
<%@page import="java.net.URL"%>
<%@page import="javax.net.ssl.HttpsURLConnection"%>
<%@page import="java.io.InputStreamReader"%>
<%@page import="java.io.BufferedReader"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
String url = request.getParameter("sslRandomUrl");
System.out.println("How to open like web browser? >>>"+url);
URL pdfContainerUrl = new URL(url);
HttpsURLConnection conn2 = (HttpsURLConnection) pdfContainerUrl.openConnection();// دقت شود https
StringBuilder result = new StringBuilder();
conn2.setRequestMethod("GET");
BufferedReader br2 = new BufferedReader(new InputStreamReader(conn2.getInputStream(), "UTF-8"));
String line2;
while ((line2 = br2.readLine()) != null) {
result.append(line2);
System.out.println(line2);
}
out.print(result);
%>
but i have this error for many URLs:
ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
How to force jdk to open all https URLs ?