При подключении и отправке данных в параметрах при запросе выходит ошибка, хотя все пути правильные, ключ доступен, адрес правильный, доступ есть.
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 targe
public static String TransHttpsAuth(String server, String param, String jksPath, String jksPass)
System.setProperty("javax.net.ssl.keyStoreType", "pkcs12"); //jks
System.setProperty("javax.net.ssl.keyStore", jksPath);
System.setProperty("javax.net.ssl.keyStorePassword", jksPass);
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
URL url = new URL(server+"/?"+ param);
System.out.println(" URL + " + url);
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();//proxy
conn.setHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
conn.setSSLSocketFactory(sslsocketfactory);
InputStream inputstream = conn.getInputStream();
InputStreamReader inputstreamreader = new InputStreamReader(inputstream);
BufferedReader bufferedreader = new BufferedReader(inputstreamreader);
String string = null;
while ((string = bufferedreader.readLine()) != null) {
result += string + "\n";
}
return result; }