사설 인증서를 통한 https 통신 기능 #4

진행중
main
icksishu@gmail.com 1 month ago
parent b4aa845927
commit 5cc486067c

@ -2,11 +2,19 @@
"description": "bsm-lab 서버에서 실행함. postgres 연결.", "description": "bsm-lab 서버에서 실행함. postgres 연결.",
"myHostId": "agent-bsm-lab-postgres", "myHostId": "agent-bsm-lab-postgres",
"myListenPort": 17801, "myListenPort": 17801,
"sslEnabled": true,
"keyStorePath": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/agent-bsm-lab-postgres/cert/dfxagent-kdn.p12",
"keyStorePassword": "qortpals1!",
"keyStoreType": "PKCS12",
"trustStorePath": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/agent-bsm-lab-postgres/cert/truststore-kdn.jks",
"trustStorePassword": "qortpals1!",
"trustStoreType": "JKS",
"knownAgentList": [ "knownAgentList": [
{ {
"hostId": "agent-tuf-a15-defree-oracle", "hostId": "agent-tuf-a15-defree-oracle",
"hostName": "bsm-lab.dev", "hostName": "bsm-lab.dev",
"listenPort": 63801, "listenPort": 63801,
"sslEnabled": true,
"dropBoxIdList": [ "dropBoxIdList": [
], ],
"routingHostIdList": [ "routingHostIdList": [
@ -45,17 +53,15 @@
"logPattern": "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n", "logPattern": "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n",
"rootLogLevel": "DEBUG", "rootLogLevel": "DEBUG",
"packages": [ "packages": [
{ {"com.bsmlab.dfx.agent": "DEBUG"},
"com.bsmlab.dfx.agent": "DEBUG", {"jdbc.timing": "DEBUG"},
"jdbc.timing": "DEBUG", {"jdbc.sqltiming": "OFF"},
"jdbc.sqltiming": "OFF", {"jdbc.sqlonly": "OFF"},
"jdbc.sqlonly": "OFF", {"jdbc.audit": "OFF"},
"jdbc.audit": "OFF", {"jdbc.resultset": "OFF"},
"jdbc.resultset": "OFF", {"jdbc.resultsettable": "OFF"},
"jdbc.resultsettable": "OFF", {"jdbc.connection": "OFF"},
"jdbc.connection": "OFF", {"org.springframework": "INFO"}
"org.springframework": "INFO"
}
] ]
}, },
"dropBoxConfig": { "dropBoxConfig": {

@ -1,13 +1,71 @@
package com.bsmlab.dfx.agent; package com.bsmlab.dfx.agent;
import com.bsmlab.dfx.agent.config.AgentConfigDto;
import com.fasterxml.jackson.databind.DatabindException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
@SpringBootApplication @SpringBootApplication
public class DfxAgentApplication { public class DfxAgentApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(DfxAgentApplication.class, args); //--setting.file=$AGENT_HOME/conf/settings.json --setting.check
// --parse.message.file
boolean hasSettingFile = false;
boolean hasSettingCheck = false;
boolean hasParseMessageFile = false;
String settingFilePath = null;
if(args != null) {
for(String arg : args) {
if(arg != null && arg.contains("setting.file")) {
if(arg.split("=").length == 2) {
settingFilePath = arg.split("=")[1].trim();
if(Files.exists(Path.of(settingFilePath))) {
hasSettingFile = true;
}
}
}
if(arg != null && arg.contains("setting.check")) {
hasSettingCheck = true;
}
if(arg != null && arg.contains("parse.message.file")) {
hasParseMessageFile = true;
}
}
}
if(hasSettingFile && !hasSettingCheck && !hasParseMessageFile) {
try {
ObjectMapper objectMapper = new ObjectMapper();
AgentConfigDto agentConfigDto = objectMapper.readValue(new File(settingFilePath), AgentConfigDto.class);
if(agentConfigDto.isSslEnabled()) {
System.setProperty("server.port", String.valueOf(agentConfigDto.getMyListenPort()));
System.setProperty("server.ssl.enabled", String.valueOf(agentConfigDto.isSslEnabled()));
System.setProperty("server.ssl.key-store", agentConfigDto.getKeyStorePath());
System.setProperty("server.ssl.key-store-password", agentConfigDto.getKeyStorePassword());
System.setProperty("server.ssl.key-store-type", "PKCS12");
System.setProperty("server.ssl.trust-store", agentConfigDto.getTrustStorePath());
System.setProperty("server.ssl.trust-store-password", agentConfigDto.getTrustStorePassword());
System.setProperty("server.ssl.trust-store-type", "JKS");
}
} catch (DatabindException e) {
System.out.println("cannot parse a setting file. " + settingFilePath);
e.printStackTrace(System.out);
} catch (IOException e) {
System.out.println("cannot read a setting file. " + settingFilePath);
e.printStackTrace(System.out);
}
SpringApplication.run(DfxAgentApplication.class, args);
}
} }
} }

@ -11,6 +11,11 @@ public class AgentConfigDto {
private String myHostId; private String myHostId;
private String myHostName; private String myHostName;
private int myListenPort; private int myListenPort;
private boolean sslEnabled;
private String keyStorePath;
private String keyStorePassword;
private String trustStorePath;
private String trustStorePassword;
private List<KnownAgent> knownAgentList; private List<KnownAgent> knownAgentList;
private StatusChecker statusChecker; private StatusChecker statusChecker;
private List<DataSourceConfig> dataSourceConfig; private List<DataSourceConfig> dataSourceConfig;
@ -26,6 +31,7 @@ public class AgentConfigDto {
private String hostId; private String hostId;
private String hostName; private String hostName;
private int listenPort; private int listenPort;
private boolean sslEnabled;
private List<String> dropBoxIdList; private List<String> dropBoxIdList;
private List<String> routingHostIdList; private List<String> routingHostIdList;
} }

Loading…
Cancel
Save