|
|
|
@ -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
|
|
|
|
|
|
|
|
|
|