From 7aa64d1bace65247ee85b114042c858123c9dc9f Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 26 Sep 2022 15:25:22 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20RedisURI.Builder.withSsl(=E2=80=A6)=20to?= =?UTF-8?q?=20retain=20peer=20verification=20mode=20#2182?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/io/lettuce/core/RedisURI.java | 2 +- .../io/lettuce/core/RedisURIBuilderUnitTests.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/lettuce/core/RedisURI.java b/src/main/java/io/lettuce/core/RedisURI.java index c076328396..521aa8d4ae 100644 --- a/src/main/java/io/lettuce/core/RedisURI.java +++ b/src/main/java/io/lettuce/core/RedisURI.java @@ -1461,7 +1461,7 @@ public Builder withSsl(RedisURI source) { LettuceAssert.notNull(source, "Source RedisURI must not be null"); withSsl(source.isSsl()); - withVerifyPeer(source.isVerifyPeer()); + withVerifyPeer(source.getVerifyMode()); withStartTls(source.isStartTls()); return this; diff --git a/src/test/java/io/lettuce/core/RedisURIBuilderUnitTests.java b/src/test/java/io/lettuce/core/RedisURIBuilderUnitTests.java index 9060d7b95a..774f4542b6 100644 --- a/src/test/java/io/lettuce/core/RedisURIBuilderUnitTests.java +++ b/src/test/java/io/lettuce/core/RedisURIBuilderUnitTests.java @@ -135,6 +135,17 @@ void redisWithSSL() { assertThat(result.isStartTls()).isTrue(); } + @Test + void redisWithSSLFromUri() { + RedisURI template = RedisURI.Builder.redis("localhost").withSsl(true).withVerifyPeer(SslVerifyMode.CA) + .withStartTls(true).build(); + RedisURI result = RedisURI.builder().withHost("localhost").withSsl(template).build(); + + assertThat(result.isSsl()).isTrue(); + assertThat(result.getVerifyMode()).isEqualTo(SslVerifyMode.CA); + assertThat(result.isStartTls()).isTrue(); + } + @Test void redisSslFromUrl() { RedisURI result = RedisURI.create(RedisURI.URI_SCHEME_REDIS_SECURE + "://:password@localhost/1");