spring-bootspring-data-redislettuce

Accessing in-transit encryption enabled Elasticache with Spring Redis, throws an error for the stringRedisTemplate.keys method


We have an in-transit encryption enabled AWS Elasticache instance. We're trying to access the instance from our Spring boot microservice with Spring data redis SSL enabled.

LettuceClientConfiguration clientConfig = LettuceClientConfiguration.builder()
                .useSsl().and()
                .shutdownTimeout(Duration.ZERO)
                .build();
return new LettuceConnectionFactory(new RedisStandaloneConfiguration(redisHost, redisPort), clientConfig);

But enabling SSL gives an error, for the method StringRedisTemplate.keys()

io.lettuce.core.RedisCommandExecutionException: ERR unknown command 'keys', with args beginning with: IndexKey:abc_prefix*

Can this be due to some restriction with the method StringRedisTemplate.keys(), with enabling SSL. This method works fine when SSL is diabled.


Solution

  • Spring boot RedisTemplate, keys method has the annotation @SuppressWarnings("unchecked")

    @SuppressWarnings("unchecked")
    public Set<K> keys(K pattern) {}
    

    When I replace the keys method with Scan, the issue got resolved.

    I think the issue was the security risks with using the keys method.