사설 인증서를 통한 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 {
mavenCentral()
maven {

@ -4,11 +4,6 @@
"myHostName": "agent-bsm-lab-postgres",
"myListenPort": 17801,
"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": [
{
"hostId": "agent-tuf-a15-defree-oracle",

@ -4,11 +4,6 @@
"myHostName": "agent-tuf-a15-defree-oracle",
"myListenPort": 63801,
"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": [
{
"hostId": "agent-bsm-lab-postgres",

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

@ -12,11 +12,6 @@ public class AgentConfigDto {
private String myHostName;
private int myListenPort;
private boolean sslEnabled;
private String keyStorePath;
private String keyStorePassword;
private String keyStoreAlias;
private String trustStorePath;
private String trustStorePassword;
private List<KnownAgent> knownAgentList;
private StatusChecker statusChecker;
private List<DataSourceConfig> dataSourceConfig;

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

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

Loading…
Cancel
Save