5

I am working on automating the API testing using Rest assured. I have one API in which if we call that API using http then server would return response code as 302 and location as same URL but with https . I ahve written the below code:

RequestSpecification httprequest= RestAssured.given().relaxedHTTPSValidation();
Response response= httprequest.request(Method.GET, uri);

On executing the above, system is throwing an error javax.net.ssl.SSLHandshakeException

I have searched a lot but got no proper solution to this.

Derrick
  • 3,669
  • 5
  • 35
  • 50
user35253
  • 143
  • 1
  • 8

1 Answers1

2

I've had my share of headaches with Rest-Assured. I'm not sure if you gave us enough to go on here but from what I can tell you're making an HTTPS call using relaxed HTTPS validation but your API is enforcing SSL. It works when you send over HTTP because its not secure anyway and not enforcing security. Try running it for HTTPS like this:

RequestSpecification httprequest= RestAssured.given();
Response response= httprequest.request(Method.GET, uri);

The .relaxedHTTPSValidation() is only necessary if you're attempting an unsecured connection on purpose and want to get around the warning as if using a self-signed certificate or http.