Rest assured : Bypassing SSL certificate

While working with API testing, we encounter SSL certificate error in testing environment.
It results into below error while executing automation script.

sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: signature check failed
javax.net.ssl.SSLHandshakeException

Here is a way to bypass checking for SSL certificate while Rest assured call.
Rest assured has inbuilt option and we do not have to write any other java code to do the same.

Example 1:
RestAssured.baseURI = “http://abcd.com”;

//ByPass SSL Certificate
RestAssured.useRelaxedHTTPSValidation();

RequestSpecification httpRequest = RestAssured.given();

httpRequest.request(Method.GET, “/resource”);

Example 2:
given(). useRelaxedHTTPSValidation().when().get( “http://abcd.com/ resource ” );

Example 3:
We can also pass TLS with the same approach.
given(). useRelaxedHTTPSValidation(“TLS”).when().get( “http://abcd.com/ resource ” );

Leave a Reply