Skip to content

Commit

Permalink
Address code review
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 committed Dec 18, 2024
1 parent 5357b68 commit 9d13917
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/main/java/redis/clients/jedis/SslOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

/**
* Options to configure SSL options for the connections kept to Redis servers.
*
* @author Mark Paluch
*/
public class SslOptions {

Expand Down Expand Up @@ -274,11 +276,23 @@ public Builder truststore(Resource resource, char[] truststorePassword) {
return this;
}

/**
* Sets a configured {@link SSLParameters}.
*
* @param sslParameters a {@link SSLParameters} object.
* @return {@code this}
*/
public Builder sslParameters(SSLParameters sslParameters) {
this.sslParameters = sslParameters;
return this;
}

/**
* Sets the {@link SslVerifyMode}.
*
* @param sslVerifyMode the {@link SslVerifyMode}.
* @return {@code this}
*/
public Builder sslVerifyMode(SslVerifyMode sslVerifyMode) {
this.sslVerifyMode = sslVerifyMode;
return this;
Expand Down Expand Up @@ -316,6 +330,7 @@ public SslOptions build() {
*/
public SSLContext createSslContext() throws IOException, GeneralSecurityException {

KeyManager[] keyManagers = null;
TrustManager[] trustManagers = null;

if (sslVerifyMode == SslVerifyMode.FULL) {
Expand All @@ -326,7 +341,6 @@ public SSLContext createSslContext() throws IOException, GeneralSecurityExceptio
trustManagers = new TrustManager[] { INSECURE_TRUST_MANAGER };
}

KeyManager[] keyManagers = null;
if (keystoreResource != null) {

KeyStore keyStore = KeyStore.getInstance(keyStoreType);
Expand All @@ -339,9 +353,7 @@ public SSLContext createSslContext() throws IOException, GeneralSecurityExceptio
keyManagers = keyManagerFactory.getKeyManagers();
}

if (trustManagers != null) {
// already processed
} else if (truststoreResource != null) {
if (trustManagers == null && truststoreResource != null) {

KeyStore trustStore = KeyStore.getInstance(trustStoreType);
try (InputStream truststoreStream = truststoreResource.get()) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/redis/clients/jedis/SslVerifyMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
public enum SslVerifyMode {

/**
* DO NOT USE THIS IN PRODUCTION.
* <p>
* No verification at all.
*/
INSECURE,
Expand Down

0 comments on commit 9d13917

Please sign in to comment.