Skip to content
Advertisement

Make Feign client to take truststore from custom property

Feign client in our app is communicating with a self-signed server. We are able to make Feign client use the custom truststore using the property javax.net.ssl.trustStore system property. But because my app also communicates with standard CA certified sites, the default truststore shouldn’t be overridden.

How can I use the custom truststore without using javax.net.ssl.trustStore system property? Or else how can I have my Feign client use the truststore from a property other than standard javax.net.ssl.trustStore system property?

Advertisement

Answer

I ended up handcrafting my own instance of SSLSocketFactory that I pass to my Feign client, using the below code,

JavaScript

And when I instantiate my client, I do it like,

JavaScript

This gist contains sample code and its usage.

Advertisement