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

- 테스트 완료
main
icksishu@gmail.com 1 week ago
parent f4b56a1c7b
commit f0a35766b8

@ -33,6 +33,11 @@ configurations {
} }
} }
bootRun {
// jvm -D
systemProperties System.properties
}
repositories { repositories {
mavenCentral() mavenCentral()
maven { maven {

@ -4,11 +4,6 @@
"myHostName": "agent-bsm-lab-postgres", "myHostName": "agent-bsm-lab-postgres",
"myListenPort": 17801, "myListenPort": 17801,
"sslEnabled": true, "sslEnabled": true,
"keyStorePath": "file:/D:/projects/bsm-lab/dfx/dfxagent/src/docs/agent-bsm-lab-postgres/cert/dfxagent-bsm-lab-postgres.p12",
"keyStorePassword": "qortpals1!",
"keyStoreAlias": "agent-bsm-lab-postgres",
"trustStorePath": "file:/D:/projects/bsm-lab/dfx/dfxagent/src/docs/agent-bsm-lab-postgres/cert/truststore-merged.jks",
"trustStorePassword": "changeit",
"knownAgentList": [ "knownAgentList": [
{ {
"hostId": "agent-tuf-a15-defree-oracle", "hostId": "agent-tuf-a15-defree-oracle",

@ -4,11 +4,6 @@
"myHostName": "agent-tuf-a15-defree-oracle", "myHostName": "agent-tuf-a15-defree-oracle",
"myListenPort": 63801, "myListenPort": 63801,
"sslEnabled": true, "sslEnabled": true,
"keyStorePath": "file:/D:/projects/bsm-lab/dfx/dfxagent/src/docs/agent-tuf-a15-defree-oracle/cert/dfxagent-tuf-a15-defree-oracle.p12",
"keyStorePassword": "qortpals1!",
"keyStoreAlias": "agent-tuf-a15-defree-oracle",
"trustStorePath": "file:/D:/projects/bsm-lab/dfx/dfxagent/src/docs/agent-tuf-a15-defree-oracle/cert/truststore-merged.jks",
"trustStorePassword": "changeit",
"knownAgentList": [ "knownAgentList": [
{ {
"hostId": "agent-bsm-lab-postgres", "hostId": "agent-bsm-lab-postgres",

@ -53,30 +53,29 @@ public class DfxAgentApplication {
if(agentConfigDto.isSslEnabled()) { if(agentConfigDto.isSslEnabled()) {
props.put("server.port", agentConfigDto.getMyListenPort()); props.put("server.port", agentConfigDto.getMyListenPort());
props.put("server.ssl.enabled", agentConfigDto.isSslEnabled()); props.put("server.ssl.enabled", agentConfigDto.isSslEnabled());
props.put("server.ssl.key-store", agentConfigDto.getKeyStorePath()); props.put("server.ssl.key-store", System.getProperty("javax.net.ssl.keyStore"));
String keyStoreFilePath = agentConfigDto.getKeyStorePath(); String keyStoreFilePath = String.valueOf(props.get("server.ssl.key-store"));
if(keyStoreFilePath.startsWith("file:")) { if(keyStoreFilePath.startsWith("file:/")) {
keyStoreFilePath = keyStoreFilePath.substring(5); keyStoreFilePath = keyStoreFilePath.substring(6);
} }
File keyStoreFile = new File(keyStoreFilePath); File keyStoreFile = new File(keyStoreFilePath);
if(!keyStoreFile.exists()) { if(!keyStoreFile.exists()) {
System.out.println("cannot find a keystore file: " + keyStoreFilePath); System.out.println("cannot find a keystore file: " + keyStoreFilePath);
System.exit(0); System.exit(0);
} }
props.put("server.ssl.key-store-password", agentConfigDto.getKeyStorePassword()); props.put("server.ssl.key-store-password", System.getProperty("javax.net.ssl.keyStorePassword"));
props.put("server.ssl.key-alias", agentConfigDto.getKeyStoreAlias()); props.put("server.ssl.key-store-type", System.getProperty("javax.net.ssl.keyStoreType"));
props.put("server.ssl.key-store-type", "PKCS12"); props.put("server.ssl.trust-store", System.getProperty("javax.net.ssl.trustStore"));
props.put("server.ssl.trust-store", agentConfigDto.getTrustStorePath()); String trustStoreFilePath = String.valueOf(props.get("server.ssl.trust-store"));
String trustStoreFilePath = agentConfigDto.getTrustStorePath(); if(trustStoreFilePath.startsWith("file:/")) {
if(trustStoreFilePath.startsWith("file:")) { trustStoreFilePath = trustStoreFilePath.substring(6);
trustStoreFilePath = trustStoreFilePath.substring(5);
} }
File trustStoreFile = new File(trustStoreFilePath); File trustStoreFile = new File(trustStoreFilePath);
if(!trustStoreFile.exists()) { if(!trustStoreFile.exists()) {
System.out.println("cannot find a truststore file: " + trustStoreFilePath); System.out.println("cannot find a truststore file: " + trustStoreFilePath);
System.exit(0); System.exit(0);
} }
props.put("server.ssl.trust-store-password", agentConfigDto.getTrustStorePassword()); props.put("server.ssl.trust-store-password", System.getProperty("javax.net.ssl.trustStorePassword"));
props.put("server.ssl.trust-store-type", "JKS"); props.put("server.ssl.trust-store-type", "JKS");
props.put("server.ssl.client-auth", "need"); props.put("server.ssl.client-auth", "need");
} }

@ -12,11 +12,6 @@ public class AgentConfigDto {
private String myHostName; private String myHostName;
private int myListenPort; private int myListenPort;
private boolean sslEnabled; private boolean sslEnabled;
private String keyStorePath;
private String keyStorePassword;
private String keyStoreAlias;
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;

@ -27,6 +27,7 @@ public class StartupRunner implements ApplicationRunner {
@Override @Override
public void run(ApplicationArguments args) throws Exception { public void run(ApplicationArguments args) throws Exception {
log.info("✅ StartupRunner 기동"); log.info("✅ StartupRunner 기동");
log.debug("System.getProperties(): \n{}", System.getProperties());
// DfxAgentConfiguration 에서 생성한 빈 중 DataSource 관련 설정을 마무리한다. // DfxAgentConfiguration 에서 생성한 빈 중 DataSource 관련 설정을 마무리한다.
dynamicDataSourceService.setSqlSessionFactoryMap(dfxAgentConfiguration.getTemporarySqlSessionFactoryMap()); dynamicDataSourceService.setSqlSessionFactoryMap(dfxAgentConfiguration.getTemporarySqlSessionFactoryMap());
dynamicDataSourceService.setTransactionManagerMap(dfxAgentConfiguration.getTemporaryTransactionManagerMap()); dynamicDataSourceService.setTransactionManagerMap(dfxAgentConfiguration.getTemporaryTransactionManagerMap());

@ -286,12 +286,12 @@ public class MessageUtils {
log.debug("StatusChecker to {} send a message UUID {}", knownAgent.getHostName(), messageUuid); log.debug("StatusChecker to {} send a message UUID {}", knownAgent.getHostName(), messageUuid);
String response = ""; String response = "";
AckDto ackDto = null; AckDto ackDto = null;
try { // try {
response = restTemplate.postForObject(url, bodyEntity, String.class); response = restTemplate.postForObject(url, bodyEntity, String.class);
} // }
catch(Exception e) { // catch(Exception e) {
log.error("send a alive message: response = restTemplate.postForObject(url, bodyEntity, String.class);", e); // log.error("send a alive message: response = restTemplate.postForObject(url, bodyEntity, String.class);", e);
} // }
ackDto = objectMapper.readValue(response, new TypeReference<AckDto>() {}); ackDto = objectMapper.readValue(response, new TypeReference<AckDto>() {});
return ackDto; return ackDto;
} }

Loading…
Cancel
Save