Configuring a keystore with a RequestSpecification

204 views
Skip to first unread message

Carlo Bertoldi

unread,
Mar 20, 2021, 7:35:22 AM3/20/21
to REST assured
Hi everybody,

I am new to Rest Assured and I am experimenting with one of my favourite topics: certificate authentication.

I managed to get it working for a single request the following way:

.auth()
.certificate("keystore.jks", "password",
CertificateAuthSettings.certAuthSettings().sslSocketFactory(sslSocketFactory))

where sslSocketFactory is a custom factory that refers to a key store containing the client certificate and the standard JRE trust store. 

Now I would like achieve the same result using a RequestSpecification, to avoid repeating the same ceremony for every test method.
I've used a RequestSpecBuilder with:
.setKeyStore(SSLSocketFactoryBuilder.buildKeyStore())
.setTrustStore(SSLSocketFactoryBuilder.buildTrustStore())

where the buildKeyStore and buildTrustStore return a KeyStore instance, the same used by the SSLSocketFactory in the previous snippet.

.setTrustStore works fine, but setKeyStore throws the following exception:

groovy.lang.MissingMethodException: No signature of method: io.restassured.config.SSLConfig.keyStore() is applicable for argument types: (java.security.KeyStore) values: [java.security.KeyStore@10567255]
Possible solutions: keyStore(java.lang.String), keyStore(java.io.File, java.lang.String), keyStore(java.lang.String, java.lang.String), getKeyStore(), trustStore(java.security.KeyStore)

Am I missing something or is it a bug?

Thanks in advance,
Carlo
Reply all
Reply to author
Forward
0 new messages