2

I am using RestAssured Java library to test REST API, and need to use certificate when invoking the API. I've come across the following stackoverflow link How to make HTTPS GET call with certificate in Rest-Assured java, but none of the solution seems to work.

In RestAssure official Java Doc, I find this page: https://www.javadoc.io/doc/io.rest-assured/rest-assured/3.2.0

In the sub link that points to io.restassured.config, Class SSLConfig, there's this statement:

"Now you want to use this truststore in your client:"

 RestAssured.config = RestAssured.newConfig().sslConfig(new SSLConfig("/truststore_javanet.jks", "test1234");

"or"

 given().config(newConfig().sslConfig(new SSLConfig("/truststore_javanet.jks", "test1234")) 

Is this kidding? Because if you look at the SSLConfig constructor

SSLConfig()

It does not accept path and password string as parameter at all. And that's what my IDE says too.

Has anyone get their code working at all?

Also the usual logging functionality 'RestAssured log.all()' does not seem to log any certificate related info when sending http requests.

Even if I made up some code like:

RestAssured.config = newConfig().sslConfig(new SSLConfig().trustStore("src/test/resources/certs/trust.jks", "password"));

It does not throw error if I give a non-existing file path value for the parameter.

So I am stuck. With no sample code to follow, or RestAssured printing any helpful info for me to debug certificate related issue.

halfer
  • 19,824
  • 17
  • 99
  • 186
user1559625
  • 2,583
  • 5
  • 37
  • 75
  • Did you happen to check this [link](https://github.com/rest-assured/rest-assured/blob/master/examples/rest-assured-itest-java/src/test/java/io/restassured/itest/java/SSLITest.java), there are quite a lot of examples using the jks – Wilfred Clement Apr 30 '19 at 10:46
  • 1
    @Wilfred Clement Thanks, man! I found this link via google too. It seems to lead to something that can actually work. Appreciate your help. – user1559625 Apr 30 '19 at 23:49

0 Answers0