Skip to content

Commit 55ac61a

Browse files
committed
Merge branch 'main' into 06/10/26/certs_as_string
2 parents f2ac4b0 + 8353658 commit 55ac61a

8 files changed

Lines changed: 250 additions & 120 deletions

File tree

.github/workflows/analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Analysis
1+
name: Coverage
22

33
on:
44
push:
@@ -94,13 +94,13 @@ jobs:
9494
find . -type f -name "simplelogger.*" -exec rm -fv '{}' \;
9595
mvn -q --no-transfer-progress --batch-mode -DclickhouseVersion=$PREFERRED_LTS_VERSION \
9696
-DskipTests install
97-
- name: Analyze
97+
- name: Generate coverage report
9898
env:
9999
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
100100
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
101101
run: |
102102
mvn -fn --no-transfer-progress --batch-mode -DclickhouseVersion=$PREFERRED_LTS_VERSION \
103-
-Panalysis verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=ClickHouse_clickhouse-java
103+
-Pcoverage verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=ClickHouse_clickhouse-java
104104
continue-on-error: true
105105
- name: Generate and post coverage report
106106
env:

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,8 @@ performance/jmh-simple-results.json
6060
*.csv
6161
*.sql
6262
*.json
63+
64+
*.crt
65+
*.key
66+
*.srl
67+
*.csr

CONTRIBUTING.md

Lines changed: 208 additions & 107 deletions
Large diffs are not rendered by default.

examples/client-v2/README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,12 @@ openssl req -newkey rsa:2048 -nodes \
135135
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial \
136136
-days 365 -out server.crt \
137137
-extfile <(printf "subjectAltName=DNS:localhost,IP:127.0.0.1")
138+
139+
# Only for demo purpose we make key readable by all. On production should be readable only by owner, not even by group.
140+
chmod a+r server.key
138141
```
139142

140-
2. Create a `config.d` overlay enabling the HTTPS interface, e.g. `zzz_ssl.xml`:
143+
2. Create a `config.d` overlay enabling the HTTPS interface, e.g. `my_ssl.xml`:
141144

142145
```xml
143146
<clickhouse>
@@ -161,11 +164,22 @@ openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial \
161164
docker run -d --name clickhouse-ssl -p 8443:8443 \
162165
-v "$PWD/server.crt:/etc/clickhouse-server/certs/server.crt:ro" \
163166
-v "$PWD/server.key:/etc/clickhouse-server/certs/server.key:ro" \
164-
-v "$PWD/zzz_ssl.xml:/etc/clickhouse-server/config.d/zzz_ssl.xml:ro" \
167+
-v "$PWD/my_ssl.xml:/etc/clickhouse-server/config.d/my_ssl.xml:ro" \
168+
-e CLICKHOUSE_PASSWORD="secret" \
165169
clickhouse/clickhouse-server:latest
166170
```
167171

168172
4. Run the example in standalone mode with `-DchHost=localhost -DchRootCert="$PWD/ca.crt"`.
169173

174+
```shell
175+
mvn exec:java -Dexec.mainClass="com.clickhouse.examples.client_v2.SSLExamples" \
176+
-DchHost="localhost" \
177+
-DchPort="8443" \
178+
-DchUser="default" \
179+
-DchPassword="secret" \
180+
-DchDatabase="default" \
181+
-DchRootCert="$PWD/ca.crt"
182+
```
183+
170184
The full description of the server-side TLS configuration is in the official documentation:
171185
[Configuring SSL-TLS](https://clickhouse.com/docs/en/guides/sre/configuring-ssl).

examples/client-v2/src/main/java/com/clickhouse/examples/client_v2/SSLExamples.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@ public static void main(String[] args) {
8282
SecureServerSupport.USER, SecureServerSupport.PASSWORD, server.getCaCertPath());
8383
} catch (Exception e) {
8484
log.error("Failed to run the SSL example against a local Docker server", e);
85-
Runtime.getRuntime().exit(-1);
8685
}
87-
// Explicit exit: testcontainers keeps non-daemon threads alive after the scenario is done.
88-
Runtime.getRuntime().exit(0);
8986
}
9087

9188
/**

examples/client-v2/src/main/java/com/clickhouse/examples/client_v2/SecureServerSupport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private SecureServerSupport(GenericContainer<?> container, Path certDir, Path co
8282
public static SecureServerSupport start(String image) throws Exception {
8383
Path certDir = Files.createTempDirectory("ch-ssl-example-certs-");
8484
Path confDir = Files.createTempDirectory("ch-ssl-example-config-");
85-
Path sslConfig = confDir.resolve("zzz_ssl.xml");
85+
Path sslConfig = confDir.resolve("custom_ca_ssl.xml");
8686

8787
log.info("Generating an ephemeral private CA and a server certificate in {}", certDir);
8888
generatePrivateCaAndServerCertificate(certDir);
@@ -100,7 +100,7 @@ public static SecureServerSupport start(String image) throws Exception {
100100
.withFileSystemBind(certDir.toAbsolutePath().toString(),
101101
"/etc/clickhouse-server/certs", BindMode.READ_ONLY)
102102
.withFileSystemBind(sslConfig.toAbsolutePath().toString(),
103-
"/etc/clickhouse-server/config.d/zzz_ssl.xml", BindMode.READ_ONLY)
103+
"/etc/clickhouse-server/config.d/custom_ca_ssl.xml", BindMode.READ_ONLY)
104104
.waitingFor(Wait.forHttp("/ping")
105105
.forPort(HTTP_PORT)
106106
.forStatusCode(200)

examples/jdbc/README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,12 @@ openssl req -newkey rsa:2048 -nodes \
7979
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial \
8080
-days 365 -out server.crt \
8181
-extfile <(printf "subjectAltName=DNS:localhost,IP:127.0.0.1")
82+
83+
# Only for demo purpose we make key readable by all. On production should be readable only by owner, not even by group.^M
84+
chmod a+r server.key
8285
```
8386

84-
2. Create a `config.d` overlay enabling the HTTPS interface, e.g. `zzz_ssl.xml`:
87+
2. Create a `config.d` overlay enabling the HTTPS interface, e.g. `my_ssl.xml`:
8588

8689
```xml
8790
<clickhouse>
@@ -105,12 +108,22 @@ openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial \
105108
docker run -d --name clickhouse-ssl -p 8443:8443 \
106109
-v "$PWD/server.crt:/etc/clickhouse-server/certs/server.crt:ro" \
107110
-v "$PWD/server.key:/etc/clickhouse-server/certs/server.key:ro" \
108-
-v "$PWD/zzz_ssl.xml:/etc/clickhouse-server/config.d/zzz_ssl.xml:ro" \
111+
-v "$PWD/my_ssl.xml:/etc/clickhouse-server/config.d/my_ssl.xml:ro" \
112+
-e CLICKHOUSE_PASSWORD="secret" \
109113
clickhouse/clickhouse-server:latest
110114
```
111115

112116
4. Run the example in standalone mode with
113117
`-DchUrl="jdbc:clickhouse://localhost:8443/default" -DchRootCert="$PWD/ca.crt"`.
114118

119+
```shell
120+
mvn exec:java -Dexec.mainClass="com.clickhouse.examples.jdbc.SSLExamples" \
121+
-DchUrl="jdbc:clickhouse:https://localhost:8443/default" \
122+
-DchUser="default" \
123+
-DchPassword="secret" \
124+
-DchRootCert="$PWD/ca.crt"
125+
```
126+
127+
115128
The full description of the server-side TLS configuration is in the official documentation:
116129
[Configuring SSL-TLS](https://clickhouse.com/docs/en/guides/sre/configuring-ssl).

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@
626626

627627
<profiles>
628628
<profile>
629-
<id>analysis</id>
629+
<id>coverage</id>
630630
<build>
631631
<plugins>
632632
<plugin>

0 commit comments

Comments
 (0)