Skip to content

Commit

Permalink
Fix RedisURI.Builder.withSsl(…) to retain peer verification mode #2182
Browse files Browse the repository at this point in the history
  • Loading branch information
mp911de committed Sep 26, 2022
1 parent 76c995e commit e5bc969
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/RedisURI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/io/lettuce/core/RedisURIBuilderUnitTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit e5bc969

Please sign in to comment.