0

I am running a JUnit test for JAX-RS GET request using RestAssured. I am making a call to a "http" url below

given().request().log().all().accept(ContentType.JSON).auth().basic(this.testUser,this.testPassword).cookie(testCookie).response().log().all().get(HTTP_TEST_URL).then().statusCode(200).contentType(ContentType.JSON);

and I get following error:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed ... Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Since I am using "http" and not "https" I fail to understand the SSLException.

Any help on the same would be highly appreciated!

sahana
  • 71
  • 1
  • 1
  • 2
  • What is the value of HTTP_TEST_URL? You may also want to try `curl --verbose ` to see what kind of a response you get back. You may be getting a redirect to an https website. – Jason Hoetger Sep 14 '16 at 01:08
  • As you providing username and password, it might happen that server is automatically redirecting you to https. In that case you would need to add certificate to the jvm truststore (cacerts). Try hitting that url with the browser and see if you are redirected to https. – Gas Sep 14 '16 at 07:52
  • Yes, it does redirect to https. But I have added a certificate added to jvm truststore. Yet I get the same exception. It works fine when I use a rest client but when I run the test in eclipse, it gives me the exception. – sahana Sep 14 '16 at 14:51
  • Try the following before the actual call. RestAssured.useRelaxedHTTPSValidation("TLSv1.2"); – Vamsi Ravi Apr 22 '19 at 18:23

0 Answers0