I want to perform a rest call using org.springframework.web.reactive.function.client.WebClient
The correspondent curl
command is this one:
curl -k --cert xxx.crt
--key yyy.key
--cacert ca.crt
-H "MyHEADER: userX"
-H "Content-Type: application/json"
https://host:1234/users -d '{"id":"XXXXX"}'
This is what I did so far:
WebClient client = WebClient.create("https://host:1234");
Mono<ClientResponse> result = client.get()
.uri("/users")
.headers(httpHeaders -> httpHeaders.add("MyHEADER","userX"))
.accept(MediaType.APPLICATION_JSON)
.exchange();
How can I specify the certificates?
I tried to configure the sslContext following this: Spring 5 WebClient using ssl but I get the exception: javax.net.ssl.SSLException: Received fatal alert: handshake_failure
I suppose that I have to specify the client certificates for the SSL client authentication ( In the curl command I use --cert xxx.crt --key yyy.key). How can I do the same in Spring/java?