`
public class TestaRest {
public static void main(String[] args) {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
JSONObject jSonPass = new JSONObject();
jSonPass.put("password", "00000000");
RequestBody body = RequestBody.create(mediaType, jSonPass.toString() );
Request request = new Request.Builder()
.url("https://126.1.3.13/sys/log_in")
.method("PUT", body)
.addHeader("Referer", "https://126.1.3.13")
.addHeader("Content-Type", "application/json")
.build();
try {
Response response = client.newCall(request).execute();
System.out.println( response );
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Estou tentando fazer um put para esta url: https://126.1.3.13/sys/log_in e está dando o seguinte erro:
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 at sun.security.ssl.Alert.createSSLException(Unknown Source) at sun.security.ssl.TransportContext.fatal(Unknown Source) at sun.security.ssl.TransportContext.fatal(Unknown Source) at sun.security.ssl.TransportContext.fatal(Unknown Source) at sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(Unknown Source) at sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate(Unknown Source) at sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(Unknown Source) at sun.security.ssl.SSLHandshake.consume(Unknown Source) at sun.security.ssl.HandshakeContext.dispatch(Unknown Source)