Skip to content

Commit

Permalink
Merge pull request #1634 from mroccyen/issue-1628
Browse files Browse the repository at this point in the history
[ISSUE #1628] Config of SSLContextFactory configure in EventMeshHTTPConfiguration
close #1628
  • Loading branch information
xwm1992 authored Oct 18, 2022
2 parents 23ae1d3 + 17fd139 commit 94760c2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 94760c2

Please sign in to comment.