I am getting the below java exception for API which i am triggering from eclipse, JAVA Version : 1.8 IDE : Eclipse Exception :"javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target"

Pre Condition : It is a 3rd party tool which we use and To login this URL we need to login ZScaler and then basic auth will call.

Tried Below thing,

  1. Install jdk 1.8 and configured java home path to jdk 1.8
  2. Eclipse-Project Run Configuration : Java Build Path set to jdk 1.8
  3. Added root cert to cacerts using keystore ["C:\Program Files\Java\jre8\lib\security\cacerts"]
  4. re stared my system and ran again

To import Cert used below command "keytool -importcert -file location_of_cert -alias cd12 -keystore "C:\Program Files\Java\jre8\lib\security\cacerts"

Just for Ref, I am trying below code in rest assured, but getting above exception,

RestAssured.proxy("ipaddress", portno); //RestAssured.useRelaxedHTTPSValidation("TLSv1.2"); RestAssured .given() .auth().basic("username", "Pwd") .contentType(ContentType.JSON) .baseUri("https://apiURL")
.when() .get() .then() .assertThat() //.body(null, null, null) .statusCode(200);

0

There are 0 best solutions below