|
1 | 1 | package com.clickhouse.client; |
2 | 2 |
|
| 3 | +import com.clickhouse.client.api.ClickHouseException; |
3 | 4 | import com.clickhouse.client.api.Client; |
4 | 5 | import com.clickhouse.client.api.ClientConfigProperties; |
5 | 6 | import com.clickhouse.client.api.ClientException; |
6 | 7 | import com.clickhouse.client.api.ClientFaultCause; |
7 | 8 | import com.clickhouse.client.api.ClientMisconfigurationException; |
8 | 9 | import com.clickhouse.client.api.ConnectionInitiationException; |
9 | 10 | import com.clickhouse.client.api.ConnectionReuseStrategy; |
| 11 | +import com.clickhouse.client.api.DataTransferException; |
10 | 12 | import com.clickhouse.client.api.ServerException; |
11 | 13 | import com.clickhouse.client.api.Session; |
12 | 14 | import com.clickhouse.client.api.command.CommandResponse; |
|
59 | 61 | import org.testng.annotations.DataProvider; |
60 | 62 | import org.testng.annotations.Test; |
61 | 63 |
|
| 64 | +import javax.net.ssl.SSLHandshakeException; |
62 | 65 | import java.io.ByteArrayInputStream; |
63 | 66 | import java.io.ByteArrayOutputStream; |
64 | 67 | import java.io.StringWriter; |
@@ -437,6 +440,18 @@ public void testSSLModeStrictWithTrustStoreAndCaCertificate() { |
437 | 440 | } |
438 | 441 |
|
439 | 442 | ClickHouseNode secureServer = getSecureServer(ClickHouseProtocol.HTTP); |
| 443 | + // A trust store and a CA certificate cannot both take effect: the trust store is used and the |
| 444 | + // CA certificate is ignored (a warning is logged). The connection still succeeds via the trust store. |
| 445 | + try (Client client = new Client.Builder() |
| 446 | + .addEndpoint("https://localhost:" + secureServer.getPort()) |
| 447 | + .setUsername("default") |
| 448 | + .setPassword(ClickHouseServerForTest.getPassword()) |
| 449 | + .build()) { |
| 450 | + ClientException ex = Assert.expectThrows(ClientException.class, () -> client.queryAll("SELECT timezone()")); |
| 451 | + |
| 452 | + Assert.assertTrue(ex.getCause() instanceof ClickHouseException); |
| 453 | + Assert.assertTrue(ex.getCause().getMessage().startsWith("SSL Problem")); |
| 454 | + } |
440 | 455 |
|
441 | 456 | // A trust store and a CA certificate cannot both take effect: the trust store is used and the |
442 | 457 | // CA certificate is ignored (a warning is logged). The connection still succeeds via the trust store. |
|
0 commit comments