bjoern
bjoern

Reputation: 1019

Have ribbon use a custom SSLContext

I have a spring boot app with zuul and ribbon (no eureka) and I need to forward all traffic over https with mutual tls. The keystore and password are all automatically generated by an internal framework. At the end I end up with an SSLContext spring bean which I would like ribbon to use when forwarding zuul requests. Now my question is how do I force ribbon to use my SSLContext?

Thanks in advance!

Upvotes: 2

Views: 699

Answers (1)

bjoern
bjoern

Reputation: 1019

I figured it out. You need to register your own SSLSocketFactory and initialize it with your own SSLContext. Then set the ribbon property ribbon.CustomSSLSocketFactoryClassName: full-path-to-your-CustomSslSocketFactory

public class CustomSslSocketFactory extends SSLSocketFactory {
    public CustomSslSocketFactory() throws Exception {
        super(SSLContextConfig.createSSLContext());
    }
}

Upvotes: 2

Related Questions