diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractHTTPServer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractHTTPServer.java index 008c62c7dd..75449ae11b 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractHTTPServer.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractHTTPServer.java @@ -167,7 +167,7 @@ public void start() throws Exception { super.start(); Runnable r = () -> { ServerBootstrap b = new ServerBootstrap(); - SSLContext sslContext = useTLS ? SSLContextFactory.getSslContext() : null; + SSLContext sslContext = useTLS ? SSLContextFactory.getSslContext(eventMeshHttpConfiguration) : null; b.group(this.bossGroup, this.workerGroup) .channel(NioServerSocketChannel.class) .childHandler(new HttpsServerInitializer(sslContext)) diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/SSLContextFactory.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/SSLContextFactory.java index 0d7fff5d04..80659ac2f6 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/SSLContextFactory.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/SSLContextFactory.java @@ -19,6 +19,7 @@ package org.apache.eventmesh.runtime.boot; +import org.apache.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; import org.apache.eventmesh.runtime.constants.EventMeshConstants; import org.apache.commons.lang3.StringUtils; @@ -45,15 +46,15 @@ public class SSLContextFactory { private static String pass; - public static SSLContext getSslContext() { + public static SSLContext getSslContext(EventMeshHTTPConfiguration eventMeshHttpConfiguration) { SSLContext sslContext; try { - protocol = System.getProperty("ssl.server.protocol", "TLSv1.1"); + protocol = eventMeshHttpConfiguration.eventMeshServerSSLProtocol; - fileName = System.getProperty("ssl.server.cer", "sChat2.jks"); + fileName = eventMeshHttpConfiguration.eventMeshServerSSLCer; char[] filePass = null; - pass = System.getProperty("ssl.server.pass", "sNetty"); + pass = eventMeshHttpConfiguration.eventMeshServerSSLPass; if (StringUtils.isNotBlank(pass)) { filePass = pass.toCharArray(); } diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshHTTPConfiguration.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshHTTPConfiguration.java index 287fce915a..95e06d4455 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshHTTPConfiguration.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/configuration/EventMeshHTTPConfiguration.java @@ -85,6 +85,12 @@ public class EventMeshHTTPConfiguration extends CommonConfiguration { public boolean eventMeshServerUseTls = false; + public String eventMeshServerSSLProtocol = "TLSv1.1"; + + public String eventMeshServerSSLCer = "sChat2.jks"; + + public String eventMeshServerSSLPass = "sNetty"; + public int eventMeshHttpMsgReqNumPerSecond = 15000; public int eventMeshBatchMsgRequestNumPerSecond = 20000; @@ -275,6 +281,20 @@ public void init() { eventMeshServerUseTls = Boolean.parseBoolean(StringUtils.deleteWhitespace(eventMeshServerUseTlsStr)); } + String eventMeshServerSslProtocolStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_HTTPS_SSL_PROTOCOL); + if (StringUtils.isNotEmpty(eventMeshServerSslProtocolStr)) { + eventMeshServerSSLProtocol = StringUtils.deleteWhitespace(eventMeshServerSslProtocolStr); + } + + String eventMeshServerSslCerStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_HTTPS_SSL_CER); + if (StringUtils.isNotEmpty(eventMeshServerSslCerStr)) { + eventMeshServerSSLCer = StringUtils.deleteWhitespace(eventMeshServerSslCerStr); + } + + String eventMeshServerSslPassStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_HTTPS_SSL_PASS); + if (StringUtils.isNotEmpty(eventMeshServerSslPassStr)) { + eventMeshServerSSLPass = StringUtils.deleteWhitespace(eventMeshServerSslPassStr); + } String eventMeshHttpMsgReqNumPerSecondStr = configurationWrapper.getProp(ConfKeys.KEY_EVENTMESH_SERVER_MSG_REQ_NUM_PER_SECOND); @@ -367,6 +387,12 @@ static class ConfKeys { public static final String KEY_EVENTMESH_HTTPS_ENABLED = "eventMesh.server.useTls.enabled"; + public static final String KEY_EVENTMESH_HTTPS_SSL_PROTOCOL = "eventMesh.server.ssl.protocol"; + + public static final String KEY_EVENTMESH_HTTPS_SSL_CER = "eventMesh.server.ssl.cer"; + + public static final String KEY_EVENTMESH_HTTPS_SSL_PASS = "eventMesh.server.ssl.pass"; + public static final String KEY_EVENTMESH_SERVER_MSG_REQ_NUM_PER_SECOND = "eventMesh.server.http.msgReqnumPerSecond"; public static final String KEY_EVENTMESH_SERVER_EVENTSIZE = "eventMesh.server.maxEventSize";