我可以使用我的 java 类成功连接到我的网站。
URLConnection myURLConnection=null; URL myURL=null; BufferedReader reader=null;
String mainUrl="https://example.com/ServCon/ServConI?";
StringBuilder sbPostData= new StringBuilder(mainUrl);
sbPostData.append("page=").append(mpage);
mainUrl = sbPostData.toString();
try {
//prepare connection
myURL = new URL(mainUrl);
myURLConnection = myURL.openConnection();
myURLConnection.connect();
reader= new BufferedReader(new
InputStreamReader(myURLConnection.getInputStream(),"UTF-8"));
} catch(Exception e) {
System.out.println(e);
}
但问题是当我尝试使用相同的 java 类从 jsp 文件连接时,我收到错误:
e = (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
我正在使用 Glassfish 5.1.0 jdk 1.8.0_301 和 apache Netbeans 12.5