I have a spring boot application connecting to Redis via tls and password.
I'm using the following configuration to instantiate the RedistTemplate and JedisConnection
@Bean
JedisConnectionFactory jedisConnectionFactory() {
RedisStandaloneConfiguration conf = new RedisStandaloneConfiguration(host,port);
conf.setPassword(RedisPassword.of("myPassword"));
JedisConnectionFactory jedisConFactory = null;
JedisClientConfiguration confJedis = JedisClientConfiguration.builder().useSsl().build();
jedisConFactory = new JedisConnectionFactory(conf,confJedis);
//jedisConFactory.setPassword("myPassword");
return jedisConFactory;
}
@Bean
public RedisTemplate<String, Object> redisTemplate() {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(jedisConnectionFactory());
return template;
}
I receive the following error:
class org.springframework.dao.InvalidDataAccessApiUsageExceptionNOAUTH Authentication required.; nested exception is redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.
Which seems to be an error from Redis not receiving a password.
Before enabling TLS configuration on redis I was using this configuration:
@Bean
JedisConnectionFactory jedisConnectionFactory() {
RedisStandaloneConfiguration conf = new RedisStandaloneConfiguration(host,port);
conf.setPassword(RedisPassword.of("myPassword"));
JedisConnectionFactory jedisConFactory = null;
jedisConFactory = new JedisConnectionFactory(conf);
return jedisConFactory;
}
And it was working just fine. So something in "how" I set the password in the Jedis configuration with TLS is not working, I even used the deprecated method (commented in the snippet above):
//jedisConFactory.setPassword("myPassword");
to see if it may work but without success.
Does anyone see what I'm doing wrong ?
I had the same problem and fixed it by adding .and().usePooling() to the code as follows:
JedisClientConfiguration confJedis = JedisClientConfiguration.builder().useSsl().and().usePooling().build();
I found the answer here