DATAREDIS-480 - Add support for all lettuce SSL options.

LettuceConnectionFactory now supports verifyPeer and startTls options for Redis Standalone usage.

Original pull request: #180.
CLA: 166820160311101157 (Balázs Németh)
This commit is contained in:
Balazs Nemeth
2016-03-17 17:43:55 +01:00
committed by Mark Paluch
parent 93bad424d1
commit 8edfb2b94e
2 changed files with 83 additions and 0 deletions

View File

@@ -99,6 +99,8 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea
private ClusterCommandExecutor clusterCommandExecutor;
private ClientResources clientResources;
private boolean useSsl;
private boolean verifyPeer = true;
private boolean startTls;
/**
* Constructs a new <code>LettuceConnectionFactory</code> instance with default settings.
@@ -327,6 +329,43 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea
return useSsl;
}
/**
* Sets to use verify certificate validity/hostname check when SSL is used
*
* @param verifyPeer {@literal false} not to verify hostname.
*/
public void setVerifyPeer(boolean verifyPeer) {
this.verifyPeer = verifyPeer;
}
/**
* Returns whether to verify certificate validity/hostname check when SSL is used
*
* @return
*/
public boolean isVerifyPeer() {
return verifyPeer;
}
/**
* Returns whether to issue a StartTLS
*
* @return
*/
public boolean isStartTls() {
return startTls;
}
/**
* Sets to issue StartTLS
*
* @param startTls {@literal true} to issue StartTLS
*/
public void setStartTls(boolean startTls) {
this.startTls = startTls;
}
/**
* Indicates if validation of the native Lettuce connection is enabled
*
@@ -556,6 +595,8 @@ public class LettuceConnectionFactory implements InitializingBean, DisposableBea
builder.withPassword(password);
}
builder.withSsl(useSsl);
builder.withVerifyPeer(verifyPeer);
builder.withStartTls(startTls);
builder.withTimeout(timeout, TimeUnit.MILLISECONDS);
if (clientResources != null) {
return RedisClient.create(clientResources, builder.build());