提交配置文件修改

master
qi_liang 4 years ago
parent bf8767e3f5
commit 31f3bed666
  1. 4
      proxy-client/src/main/java/org/fengfei/lanproxy/client/ProxyClientContainer.java
  2. 10
      proxy-client/src/main/java/org/fengfei/lanproxy/client/SslContextCreator.java

@ -11,7 +11,6 @@ import org.fengfei.lanproxy.client.config.Server;
import org.fengfei.lanproxy.client.handlers.ClientChannelHandler;
import org.fengfei.lanproxy.client.handlers.RealServerChannelHandler;
import org.fengfei.lanproxy.client.listener.ChannelStatusListener;
import org.fengfei.lanproxy.common.Config;
import org.fengfei.lanproxy.common.container.Container;
import org.fengfei.lanproxy.common.container.ContainerHelper;
import org.fengfei.lanproxy.protocol.IdleCheckHandler;
@ -82,7 +81,8 @@ public class ProxyClientContainer implements Container, ChannelStatusListener {
@Override
public void initChannel(SocketChannel ch) throws Exception {
if (Config.getInstance().getBooleanValue("ssl.enable", false)) {
if (clientConfig.getSsl().isEnable()) {
if (sslContext == null) {
sslContext = SslContextCreator.createSSLContext();
}

@ -16,7 +16,7 @@ import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import org.fengfei.lanproxy.common.Config;
import org.fengfei.lanproxy.client.config.ClientConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -24,13 +24,16 @@ public class SslContextCreator {
private static Logger LOGGER = LoggerFactory.getLogger(SslContextCreator.class);
private ClientConfig config = ClientConfig.getInstance();
public static SSLContext createSSLContext() {
return new SslContextCreator().initSSLContext();
}
public SSLContext initSSLContext() {
LOGGER.info("Checking SSL configuration properties...");
final String jksPath = Config.getInstance().getStringValue("ssl.jksPath");
final String jksPath = config.getSsl().getJksPath();
LOGGER.info("Initializing SSL context. KeystorePath = {}.", jksPath);
if (jksPath == null || jksPath.isEmpty()) {
// key_store_password or key_manager_password are empty
@ -41,7 +44,8 @@ public class SslContextCreator {
// if we have the port also the jks then keyStorePassword and
// keyManagerPassword
// has to be defined
final String keyStorePassword = Config.getInstance().getStringValue("ssl.keyStorePassword");
final String keyStorePassword = config.getSsl().getKeyStorePassword();
// if client authentification is enabled a trustmanager needs to be
// added to the ServerContext

Loading…
Cancel
Save