Skip to content

Commit 9d13917

Browse files
committed
Address code review
1 parent 5357b68 commit 9d13917

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/main/java/redis/clients/jedis/SslOptions.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
/**
3030
* Options to configure SSL options for the connections kept to Redis servers.
31+
*
32+
* @author Mark Paluch
3133
*/
3234
public class SslOptions {
3335

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

279+
/**
280+
* Sets a configured {@link SSLParameters}.
281+
*
282+
* @param sslParameters a {@link SSLParameters} object.
283+
* @return {@code this}
284+
*/
277285
public Builder sslParameters(SSLParameters sslParameters) {
278286
this.sslParameters = sslParameters;
279287
return this;
280288
}
281289

290+
/**
291+
* Sets the {@link SslVerifyMode}.
292+
*
293+
* @param sslVerifyMode the {@link SslVerifyMode}.
294+
* @return {@code this}
295+
*/
282296
public Builder sslVerifyMode(SslVerifyMode sslVerifyMode) {
283297
this.sslVerifyMode = sslVerifyMode;
284298
return this;
@@ -316,6 +330,7 @@ public SslOptions build() {
316330
*/
317331
public SSLContext createSslContext() throws IOException, GeneralSecurityException {
318332

333+
KeyManager[] keyManagers = null;
319334
TrustManager[] trustManagers = null;
320335

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

329-
KeyManager[] keyManagers = null;
330344
if (keystoreResource != null) {
331345

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

342-
if (trustManagers != null) {
343-
// already processed
344-
} else if (truststoreResource != null) {
356+
if (trustManagers == null && truststoreResource != null) {
345357

346358
KeyStore trustStore = KeyStore.getInstance(trustStoreType);
347359
try (InputStream truststoreStream = truststoreResource.get()) {

src/main/java/redis/clients/jedis/SslVerifyMode.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
public enum SslVerifyMode {
77

88
/**
9+
* DO NOT USE THIS IN PRODUCTION.
10+
* <p>
911
* No verification at all.
1012
*/
1113
INSECURE,

0 commit comments

Comments
 (0)