Skip to content

Commit f318d76

Browse files
authored
Solves issue #2206 (#2304)
1 parent da90573 commit f318d76

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcConfiguration.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ public JdbcConfiguration(String url, Properties info) throws SQLException {
6161
initProperties(urlProperties, info);
6262

6363
// after initializing all properties - set final connection URL
64-
boolean useSSL = Boolean.parseBoolean(info.getProperty(DriverProperties.SECURE_CONNECTION.getKey(), "false"));
64+
boolean useSSLInfo = Boolean.parseBoolean(info.getProperty(DriverProperties.SECURE_CONNECTION.getKey(), "false"));
65+
boolean useSSLUrlProperties = Boolean.parseBoolean(urlProperties.getOrDefault(DriverProperties.SECURE_CONNECTION.getKey(), "false"));
66+
boolean useSSL = useSSLInfo || useSSLUrlProperties;
6567
String bearerToken = info.getProperty(ClientConfigProperties.BEARERTOKEN_AUTH.getKey(), null);
6668
if (bearerToken != null) {
6769
clientProperties.put(ClientConfigProperties.BEARERTOKEN_AUTH.getKey(), bearerToken);

jdbc-v2/src/test/java/com/clickhouse/jdbc/internal/JdbcConfigurationTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
public class JdbcConfigurationTest {
2020

21+
2122
@Test(dataProvider = "testConnectionUrlDataProvider")
2223
public void testConnectionUrl(String jdbcUrl, String connectionUrl, Properties properties, Map<String, String> expectedClientProps) throws Exception {
2324
JdbcConfiguration configuration = new JdbcConfiguration(jdbcUrl, properties);
@@ -38,7 +39,7 @@ public static Object[][] testConnectionUrlDataProvider() {
3839
Map<String, String> useSSLParams = Map.of("ssl", "true");
3940
Map<String, String> withListParams = Map.of("database", "default", "param1", "value1", "custom_header1", "val1,val2,val3", "user", "default", "password", "");
4041
Map<String, String> withListParamsQuotes = Map.of("database", "default", "param1", "value1", "custom_header1", "\"role 1,3,4\",'val2',val3", "user", "default", "password", "");
41-
42+
Map<String, String> useDatabaseSSLParams = Map.of("database", "clickhouse", "ssl", "true", "user", "default", "password", "");
4243

4344
return new Object[][] {
4445
{"jdbc:clickhouse://localhost:8123/", "http://localhost:8123", defaultProps, defaultParams},
@@ -47,7 +48,7 @@ public static Object[][] testConnectionUrlDataProvider() {
4748
{"jdbc:clickhouse://localhost:8443/", "https://localhost:8443", useSSL, useSSLParams},
4849
{"jdbc:clickhouse://localhost:8443/default?param1=value1&custom_header1=val1,val2,val3", "http://localhost:8443", defaultProps, withListParams},
4950
{"jdbc:clickhouse://localhost:8443/default?custom_header1=\"role 1,3,4\",'val2',val3&param1=value1", "http://localhost:8443", defaultProps, withListParamsQuotes},
50-
51+
{"jdbc:clickhouse://localhost:8443/clickhouse?ssl=true", "https://localhost:8443", defaultProps, useDatabaseSSLParams},
5152
};
5253
}
5354

0 commit comments

Comments
 (0)