Skip to content

Commit 4c2fd63

Browse files
authored
Add generic SSL/TLS configuration support (#17854)
1 parent 67c69b4 commit 4c2fd63

59 files changed

Lines changed: 1011 additions & 277 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

external-service-impl/rest/pom.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@
3838
<groupId>org.glassfish.jersey.inject</groupId>
3939
<artifactId>jersey-hk2</artifactId>
4040
<scope>runtime</scope>
41-
<exclusions>
42-
<!-- repeated in node commons -->
43-
<exclusion>
44-
<groupId>jakarta.annotation</groupId>
45-
<artifactId>jakarta.annotation-api</artifactId>
46-
</exclusion>
47-
</exclusions>
4841
</dependency>
4942
<dependency>
5043
<groupId>org.apache.iotdb</groupId>
@@ -87,11 +80,6 @@
8780
<groupId>jakarta.validation</groupId>
8881
<artifactId>jakarta.validation-api</artifactId>
8982
</exclusion>
90-
<!-- repeated in node commons -->
91-
<exclusion>
92-
<groupId>jakarta.annotation</groupId>
93-
<artifactId>jakarta.annotation-api</artifactId>
94-
</exclusion>
9583
</exclusions>
9684
</dependency>
9785
<dependency>

external-service-impl/rest/src/main/java/org/apache/iotdb/rest/RestService.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.apache.iotdb.externalservice.api.IExternalService;
2222
import org.apache.iotdb.rest.i18n.RestMessages;
2323
import org.apache.iotdb.rest.protocol.filter.ApiOriginFilter;
24+
import org.apache.iotdb.rpc.RpcSslUtils;
2425

2526
import org.eclipse.jetty.ee10.servlet.ServletContextHandler;
2627
import org.eclipse.jetty.ee10.servlet.ServletHolder;
@@ -52,6 +53,7 @@ private void startSSL(
5253
String trustStorePath,
5354
String keyStorePwd,
5455
String trustStorePwd,
56+
String sslProtocol,
5557
int idleTime,
5658
boolean clientAuth) {
5759
server = new Server();
@@ -61,6 +63,7 @@ private void startSSL(
6163
httpsConfig.addCustomizer(new SecureRequestCustomizer());
6264

6365
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
66+
configureSSL(sslContextFactory, sslProtocol);
6467
sslContextFactory.setKeyStorePath(keyStorePath);
6568
sslContextFactory.setKeyStorePassword(keyStorePwd);
6669
if (clientAuth) {
@@ -125,6 +128,7 @@ public void start() {
125128
config.getTrustStorePath(),
126129
config.getKeyStorePwd(),
127130
config.getTrustStorePwd(),
131+
config.getSslProtocol(),
128132
config.getIdleTimeoutInSeconds(),
129133
config.isClientAuth());
130134
} else {
@@ -142,4 +146,9 @@ public void stop() {
142146
server.destroy();
143147
}
144148
}
149+
150+
private void configureSSL(SslContextFactory.Server sslContextFactory, String sslProtocol) {
151+
String protocol = RpcSslUtils.normalizeProtocol(sslProtocol);
152+
sslContextFactory.setProtocol(protocol);
153+
}
145154
}

integration-test/src/main/java/org/apache/iotdb/it/env/cluster/config/MppBaseConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ protected final void setProperty(@NotNull String key, String value) {
120120
}
121121
}
122122

123+
public final String getProperty(@NotNull String key, String defaultValue) {
124+
return properties.getProperty(key, defaultValue);
125+
}
126+
123127
/** Create an instance but with empty properties. */
124128
public abstract MppBaseConfig emptyClone();
125129
}

integration-test/src/main/java/org/apache/iotdb/it/env/cluster/config/MppCommonConfig.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,12 @@ public CommonConfig setEnforceStrongPassword(boolean enforceStrongPassword) {
626626
return this;
627627
}
628628

629+
@Override
630+
public CommonConfig setEnableThriftClientSSL(boolean enableThriftClientSSL) {
631+
setProperty("enable_thrift_ssl", String.valueOf(enableThriftClientSSL));
632+
return this;
633+
}
634+
629635
@Override
630636
public CommonConfig setEnableInternalSSL(boolean enableInternalSSL) {
631637
setProperty("enable_internal_ssl", String.valueOf(enableInternalSSL));
@@ -656,6 +662,12 @@ public CommonConfig setTrustStorePwd(String trustStorePwd) {
656662
return this;
657663
}
658664

665+
@Override
666+
public CommonConfig setSslProtocol(String sslProtocol) {
667+
setProperty("ssl_protocol", sslProtocol);
668+
return this;
669+
}
670+
659671
@Override
660672
public CommonConfig setDatanodeMemoryProportion(String datanodeMemoryProportion) {
661673
setProperty("datanode_memory_proportion", datanodeMemoryProportion);

integration-test/src/main/java/org/apache/iotdb/it/env/cluster/config/MppSharedCommonConfig.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,13 @@ public CommonConfig setEnforceStrongPassword(boolean enforceStrongPassword) {
651651
return this;
652652
}
653653

654+
@Override
655+
public CommonConfig setEnableThriftClientSSL(boolean enableThriftClientSSL) {
656+
cnConfig.setEnableThriftClientSSL(enableThriftClientSSL);
657+
dnConfig.setEnableThriftClientSSL(enableThriftClientSSL);
658+
return this;
659+
}
660+
654661
@Override
655662
public CommonConfig setEnableInternalSSL(boolean enableInternalSSL) {
656663
cnConfig.setEnableInternalSSL(enableInternalSSL);
@@ -686,6 +693,13 @@ public CommonConfig setTrustStorePwd(String trustStorePwd) {
686693
return this;
687694
}
688695

696+
@Override
697+
public CommonConfig setSslProtocol(String sslProtocol) {
698+
cnConfig.setSslProtocol(sslProtocol);
699+
dnConfig.setSslProtocol(sslProtocol);
700+
return this;
701+
}
702+
689703
@Override
690704
public CommonConfig setDatanodeMemoryProportion(String datanodeMemoryProportion) {
691705
dnConfig.setDatanodeMemoryProportion(datanodeMemoryProportion);

0 commit comments

Comments
 (0)