targetCert 추가

master
mjkhan21 2 months ago
parent 3a444ac31a
commit dd16efd8ec

@ -146,9 +146,12 @@ public class GPKI extends AbstractComponent {
private static void load(gpkiapi_jni gpki, String serverID) throws Exception { private static void load(gpkiapi_jni gpki, String serverID) throws Exception {
X509Certificate cert = null; X509Certificate cert = null;
String certFile = conf.certDir + File.separator + serverID + ".cer";
String certFile = conf.certDir + File.separator + conf.targetCert(serverID);
try { try {
cert = Disk.readCert(certFile); cert = Disk.readCert(certFile);
if (cert != null)
log(GPKI.class).debug(certFile + " loaded");
} catch (GpkiApiException e) { } catch (GpkiApiException e) {
cert = null; cert = null;
} }
@ -165,6 +168,7 @@ public class GPKI extends AbstractComponent {
cert = new X509Certificate(gpki.baReturnArray); cert = new X509Certificate(gpki.baReturnArray);
Disk.writeCert(certFile, cert); Disk.writeCert(certFile, cert);
log(GPKI.class).debug(certFile + " downloaded");
} }
if (cert != null) if (cert != null)
@ -262,6 +266,19 @@ public class GPKI extends AbstractComponent {
gpki = null; gpki = null;
} }
public boolean test(String serverID) {
String plain = "나랏말씀이 중국과 달라";
log().debug("plain text: {}", plain);
String encrypted = encrypt(serverID, plain);
log().debug("encrypted: {}", encrypted);
String decrypted = decrypt(encrypted);
log().debug("decrypted: {}", decrypted);
return plain.equals(decrypted);
}
/**GPKI (intf-conf/gpki.conf) . /**GPKI (intf-conf/gpki.conf) .
* JSON . * JSON .
* <pre><code> { * <pre><code> {
@ -305,7 +322,9 @@ public class GPKI extends AbstractComponent {
charset, charset,
license, license,
ldapUrl, ldapUrl,
certDir; certDir,
targetCert;
private Map<String, String> private Map<String, String>
server, server,
env, env,
@ -381,6 +400,24 @@ public class GPKI extends AbstractComponent {
this.certDir = certDir; this.certDir = certDir;
} }
/**targetCert() .
* @return targetCert
*/
public String getTargetCert() {
return ifEmpty(targetCert, () -> "{serverID}.cer");
}
public String targetCert(String serverID) {
return getTargetCert().replace("{serverID}", serverID);
}
/**targetCert() .
* @param targetCert targetCert
*/
public void setTargetCert(String targetCert) {
this.targetCert = targetCert;
}
/**server() . /**server() .
* @return server * @return server
*/ */

@ -11,6 +11,7 @@
"ldapUrl": "ldap://10.1.7.118:389/cn=", /* 대상기관 인증서 다운로드를 위한 행정망 LDAP URL */ "ldapUrl": "ldap://10.1.7.118:389/cn=", /* 대상기관 인증서 다운로드를 위한 행정망 LDAP URL */
/*"ldapUrl": "ldap://152.99.57.127:389/cn=", 대상기관 인증서 다운로드를 위한 인터넷망 LDAP URL */ /*"ldapUrl": "ldap://152.99.57.127:389/cn=", 대상기관 인증서 다운로드를 위한 인터넷망 LDAP URL */
"certDir": "C:\\GPKI\\Certificate\\class1", /* 서버 인증서, 키 저장 디렉토리 */ "certDir": "C:\\GPKI\\Certificate\\class1", /* 서버 인증서, 키 저장 디렉토리 */
"targetCert": "{serverID}.cer", /* 대상기관 서버인증서 이름 패턴 */
"env": { /* 이용기관 서버 인증서 */ "env": { /* 이용기관 서버 인증서 */
"certFile": "SVR3910262001_env.cer", "certFile": "SVR3910262001_env.cer",

Loading…
Cancel
Save