Skip to content

Commit

Permalink
SSL support: keyStoreUrl fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Veirisa committed Jan 5, 2023
1 parent 77869e9 commit 0fb2bc6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions driver/src/main/java/jdbc/client/impl/RedisJedisURIBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.KeyStore;
import java.sql.SQLException;
import java.util.HashMap;
Expand All @@ -16,6 +18,7 @@
import static jdbc.properties.RedisDefaultConfig.CONFIG;
import static jdbc.properties.RedisDriverPropertyInfoHelper.*;
import static jdbc.utils.SSLUtils.getTrustEverybodySSLContext;
import static jdbc.utils.Utils.isNullOrEmpty;
import static jdbc.utils.Utils.parseDbIndex;

public abstract class RedisJedisURIBase implements JedisClientConfig {
Expand Down Expand Up @@ -156,6 +159,14 @@ private void setSSLParameters(@NotNull Map<String, String> parameters, Propertie
String keyStoreType = System.getProperty("javax.net.ssl.keyStoreType", KeyStore.getDefaultType());
String keyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword", "");
String keyStoreUrl = System.getProperty("javax.net.ssl.keyStore", "");
// check keyStoreUrl
if (!isNullOrEmpty(keyStoreUrl)) {
try {
new URL(keyStoreUrl);
} catch (MalformedURLException e) {
keyStoreUrl = "file:" + keyStoreUrl;
}
}
SSLContext context = getTrustEverybodySSLContext(keyStoreUrl, keyStoreType, keyStorePassword);
sslSocketFactory = context.getSocketFactory();
}
Expand Down

0 comments on commit 0fb2bc6

Please sign in to comment.