Skip to content

Commit 0fb2bc6

Browse files
committed
SSL support: keyStoreUrl fix
1 parent 77869e9 commit 0fb2bc6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

driver/src/main/java/jdbc/client/impl/RedisJedisURIBase.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import javax.net.ssl.SSLContext;
99
import javax.net.ssl.SSLSocketFactory;
10+
import java.net.MalformedURLException;
11+
import java.net.URL;
1012
import java.security.KeyStore;
1113
import java.sql.SQLException;
1214
import java.util.HashMap;
@@ -16,6 +18,7 @@
1618
import static jdbc.properties.RedisDefaultConfig.CONFIG;
1719
import static jdbc.properties.RedisDriverPropertyInfoHelper.*;
1820
import static jdbc.utils.SSLUtils.getTrustEverybodySSLContext;
21+
import static jdbc.utils.Utils.isNullOrEmpty;
1922
import static jdbc.utils.Utils.parseDbIndex;
2023

2124
public abstract class RedisJedisURIBase implements JedisClientConfig {
@@ -156,6 +159,14 @@ private void setSSLParameters(@NotNull Map<String, String> parameters, Propertie
156159
String keyStoreType = System.getProperty("javax.net.ssl.keyStoreType", KeyStore.getDefaultType());
157160
String keyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword", "");
158161
String keyStoreUrl = System.getProperty("javax.net.ssl.keyStore", "");
162+
// check keyStoreUrl
163+
if (!isNullOrEmpty(keyStoreUrl)) {
164+
try {
165+
new URL(keyStoreUrl);
166+
} catch (MalformedURLException e) {
167+
keyStoreUrl = "file:" + keyStoreUrl;
168+
}
169+
}
159170
SSLContext context = getTrustEverybodySSLContext(keyStoreUrl, keyStoreType, keyStorePassword);
160171
sslSocketFactory = context.getSocketFactory();
161172
}

0 commit comments

Comments
 (0)