Reputation: 191
We're using spring-data-redis and Azure Cache for Redis. When debugging locally, the only way to connect is to use TLS, but disable the peer verification - as I understand it, Azure does something weird with the certificates which makes them fail verification (https://github.com/lettuce-io/lettuce-core/issues/1454).
It's simple enough to disable this using the builder for RedisConnectionFactory and setting configurationBuilder.useSsl().disablePeerVerification();
, but we've moved away from using a separate config file and moved all the config to application.yml. Is there an equivalent option I could add to the redis block in this file to turn off peer verification? I've been through the documentation but couldn't find anything.
Upvotes: 4
Views: 3978
Reputation: 941
In my opinion, you can use ConditionalOnProperty
and LettuceClientConfigurationBuilderCustomizer
For instance:
@Bean
@ConditionalOnProperty(
value = {"spring.redis.ssl"},
havingValue = "true"
)
public LettuceClientConfigurationBuilderCustomizer lettuceClientConfigurationBuilderCustomizer(){
return (clientConfigurationBuilder) ->{
clientConfigurationBuilder.useSsl().disablePeerVerification();
};
}
Upvotes: 3