From b2660301e52ec4f977a5a21a65aeaf2076762789 Mon Sep 17 00:00:00 2001 From: Andres Rosenthal Date: Fri, 1 Dec 2023 16:52:36 +0200 Subject: [PATCH] feat: Bump certificate hashing algo SHA1 -> SHA256 except for globalconf V2's authCertHash (#1873) * feat: Bump certificate hashing algo SHA1 -> SHA256 except for globalconf V2's authCertHash Refs: XRDDEV-445 * fix: Overflowing cert hash in the UI + CR suggestions Refs: XRDDEV-445 --- .../resources/globalconf/CS/shared-params.xml | 4 +- .../entity/mapper/ApprovedTsaMapperTest.java | 2 +- .../CertificationServicesServiceImplTest.java | 8 +- .../IntermediateCasServiceImplTest.java | 3 +- .../TimestampingServicesServiceImplTest.java | 6 +- .../generator/SharedParameters.java | 2 +- .../generator/SharedParametersLoader.java | 30 ++--- .../SharedParametersV2Converter.java | 20 ++- .../SharedParametersV3Converter.java | 20 ++- .../generator/SharedParametersLoaderTest.java | 3 +- .../SharedParametersV2ConverterTest.java | 13 +- .../SharedParametersV3ConverterTest.java | 12 +- .../certificate/CertificateHash.vue | 2 +- .../admin-service/ui/src/locales/en.json | 2 +- .../main/resources/openapi-definition.yaml | 4 +- .../etc/xroad/globalconf/CS/shared-params.xml | 4 +- .../VersionedConfigurationDirectory.java | 72 ++++++----- .../ee/ria/xroad/common/util/CryptoUtils.java | 37 ++++-- .../VersionedConfigurationDirectoryTest.java | 38 +++--- .../globalconf_good_v3/EE/shared-params.xml | 11 +- .../globalconf_good_v3/bar/shared-params.xml | 11 +- .../conf/globalconf/GlobalConfImpl.java | 118 +++++++++--------- .../ClientsApiControllerIntegrationTest.java | 8 +- ...tificatesApiControllerIntegrationTest.java | 4 +- .../restapi/util/CertificateTestUtils.java | 6 +- .../certificate/CertificateHash.vue | 2 +- .../admin-service/ui/src/locales/en.json | 2 +- .../META-INF/openapi-definition.yaml | 48 +++---- ...3000-global-conf-sign-key-rotation.feature | 4 +- .../fetchinterval-params.xml | 0 .../private-params.xml | 0 .../shared-params.xml | 8 +- .../V3/externalconf | 26 ++-- .../V3/internalconf | 30 ++--- .../fetchinterval-params.xml | 0 .../private-params.xml | 0 .../shared-params.xml | 8 +- .../var/lib/xroad/public/V3/externalconf | 24 ++-- .../var/lib/xroad/public/V3/internalconf | 34 ++--- .../tokenmanager/TokenManagerMergeTest.java | 2 +- 40 files changed, 339 insertions(+), 289 deletions(-) rename src/security-server/system-test/src/intTest/resources/files/global_conf_signed_with_rotated_keys/V3/{20231121222055281623000 => 20231129113225683586000}/fetchinterval-params.xml (100%) rename src/security-server/system-test/src/intTest/resources/files/global_conf_signed_with_rotated_keys/V3/{20231121222055281623000 => 20231129113225683586000}/private-params.xml (100%) rename src/security-server/system-test/src/intTest/resources/files/global_conf_signed_with_rotated_keys/V3/{20231121222055281623000 => 20231129113225683586000}/shared-params.xml (86%) rename src/security-server/system-test/src/intTest/resources/nginx-container-files/var/lib/xroad/public/V3/{20231121221955286271000 => 20231129113125682194000}/fetchinterval-params.xml (100%) rename src/security-server/system-test/src/intTest/resources/nginx-container-files/var/lib/xroad/public/V3/{20231121221955286271000 => 20231129113125682194000}/private-params.xml (100%) rename src/security-server/system-test/src/intTest/resources/nginx-container-files/var/lib/xroad/public/V3/{20231121221955286271000 => 20231129113125682194000}/shared-params.xml (86%) diff --git a/src/addons/messagelog/messagelog-addon/src/test/resources/globalconf/CS/shared-params.xml b/src/addons/messagelog/messagelog-addon/src/test/resources/globalconf/CS/shared-params.xml index 0c340a5113..2c054f5579 100644 --- a/src/addons/messagelog/messagelog-addon/src/test/resources/globalconf/CS/shared-params.xml +++ b/src/addons/messagelog/messagelog-addon/src/test/resources/globalconf/CS/shared-params.xml @@ -67,7 +67,7 @@ id0 SS0
ss0
- 5+C5Gr24Dh912x5haKGOyZuK2KI= + enRxKzBGb0q7sUJa8Hx0A5aHmQwCa1HzWNFrN3ZDDJw= id1 id7 @@ -75,7 +75,7 @@ id4 SS1
ss1
- 03SfHhv+L5OJrJaod/sOZn6vp1c= + Q/wASEqban646kxZ0/uveKBv4h7U3FWnlKzsSJZU1f8= id5 id6 id3 diff --git a/src/central-server/admin-service/core/src/test/java/org/niis/xroad/cs/admin/core/entity/mapper/ApprovedTsaMapperTest.java b/src/central-server/admin-service/core/src/test/java/org/niis/xroad/cs/admin/core/entity/mapper/ApprovedTsaMapperTest.java index b9531825db..da0ef7a568 100644 --- a/src/central-server/admin-service/core/src/test/java/org/niis/xroad/cs/admin/core/entity/mapper/ApprovedTsaMapperTest.java +++ b/src/central-server/admin-service/core/src/test/java/org/niis/xroad/cs/admin/core/entity/mapper/ApprovedTsaMapperTest.java @@ -75,7 +75,7 @@ void toTarget() throws Exception { assertThat(result.getValidFrom()).isEqualTo(VALID_FROM); assertThat(result.getValidTo()).isEqualTo(VALID_TO); - assertThat(result.getCertificate().getHash()).isEqualTo("05A10EEBDB0CD9679E4C85A78848145EF1F00BEA"); + assertThat(result.getCertificate().getHash()).isEqualTo("094D62D75ECC25D6BD9EA83C7B34678016BB72BB80118FF6EC7E4D383A678CD1"); assertThat(result.getCertificate().getIssuerCommonName()).isEqualTo("AdminCA1"); assertThat(result.getCertificate().getIssuerDistinguishedName()).isEqualTo("C=SE, O=EJBCA Sample, CN=AdminCA1"); assertThat(result.getCertificate().getKeyUsages()).isEqualTo(Set.of(NON_REPUDIATION)); diff --git a/src/central-server/admin-service/core/src/test/java/org/niis/xroad/cs/admin/core/service/CertificationServicesServiceImplTest.java b/src/central-server/admin-service/core/src/test/java/org/niis/xroad/cs/admin/core/service/CertificationServicesServiceImplTest.java index ff979dc868..495662aa20 100644 --- a/src/central-server/admin-service/core/src/test/java/org/niis/xroad/cs/admin/core/service/CertificationServicesServiceImplTest.java +++ b/src/central-server/admin-service/core/src/test/java/org/niis/xroad/cs/admin/core/service/CertificationServicesServiceImplTest.java @@ -195,7 +195,8 @@ void addCertificationServiceOcspResponder() throws Exception { verify(auditDataHelper).put(CA_ID, mockOcspInfo.getCaInfo().getId()); verify(auditDataHelper).put(OCSP_ID, mockOcspInfo.getId()); verify(auditDataHelper).put(OCSP_URL, mockOcspInfo.getUrl()); - verify(auditDataHelper).put(OCSP_CERT_HASH, "F5:1B:1F:9C:07:23:4C:DA:E6:4C:99:CB:FC:D8:EE:0E:C5:5F:A4:AF"); + verify(auditDataHelper).put(OCSP_CERT_HASH, + "B9:CF:6E:A1:BC:98:24:6B:16:68:24:E3:9A:9F:CD:8E:51:B7:05:37:44:68:D4:96:50:D2:22:85:A7:FA:54:2B"); verify(auditDataHelper).put(OCSP_CERT_HASH_ALGORITHM, DEFAULT_CERT_HASH_ALGORITHM_ID); } @@ -210,7 +211,7 @@ void addIntermediateCa() { final CertificateAuthority certificateAuthority = service.addIntermediateCa(ID, certificateBytes); - assertEquals("24AFDE09AA818A20D3EE7A4A2264BA247DA5C3F9", certificateAuthority.getCaCertificate().getHash()); + assertEquals("D8FD191D4155864DE4DB7F8A5E099DAF70E57AF1B62A2A9B3B3B0C2B51788994", certificateAuthority.getCaCertificate().getHash()); ArgumentCaptor captor = ArgumentCaptor.forClass(CaInfoEntity.class); verify(caInfoRepository).save(captor.capture()); @@ -220,7 +221,8 @@ void addIntermediateCa() { verify(auditDataHelper).put(CA_ID, ID); verify(auditDataHelper).put(INTERMEDIATE_CA_ID, 0); - verify(auditDataHelper).put(INTERMEDIATE_CA_CERT_HASH, "24:AF:DE:09:AA:81:8A:20:D3:EE:7A:4A:22:64:BA:24:7D:A5:C3:F9"); + verify(auditDataHelper).put(INTERMEDIATE_CA_CERT_HASH, + "D8:FD:19:1D:41:55:86:4D:E4:DB:7F:8A:5E:09:9D:AF:70:E5:7A:F1:B6:2A:2A:9B:3B:3B:0C:2B:51:78:89:94"); verify(auditDataHelper).put(INTERMEDIATE_CA_CERT_HASH_ALGORITHM, DEFAULT_CERT_HASH_ALGORITHM_ID); } diff --git a/src/central-server/admin-service/core/src/test/java/org/niis/xroad/cs/admin/core/service/IntermediateCasServiceImplTest.java b/src/central-server/admin-service/core/src/test/java/org/niis/xroad/cs/admin/core/service/IntermediateCasServiceImplTest.java index 32ea959593..45b0ecaec0 100644 --- a/src/central-server/admin-service/core/src/test/java/org/niis/xroad/cs/admin/core/service/IntermediateCasServiceImplTest.java +++ b/src/central-server/admin-service/core/src/test/java/org/niis/xroad/cs/admin/core/service/IntermediateCasServiceImplTest.java @@ -172,7 +172,8 @@ void addOcspResponder() { verify(auditDataHelper).put(INTERMEDIATE_CA_ID, ID); verify(auditDataHelper).put(OCSP_ID, NEW_ID); verify(auditDataHelper).put(OCSP_URL, URL); - verify(auditDataHelper).put(OCSP_CERT_HASH, "F5:1B:1F:9C:07:23:4C:DA:E6:4C:99:CB:FC:D8:EE:0E:C5:5F:A4:AF"); + verify(auditDataHelper).put(OCSP_CERT_HASH, + "B9:CF:6E:A1:BC:98:24:6B:16:68:24:E3:9A:9F:CD:8E:51:B7:05:37:44:68:D4:96:50:D2:22:85:A7:FA:54:2B"); verify(auditDataHelper).put(OCSP_CERT_HASH_ALGORITHM, DEFAULT_CERT_HASH_ALGORITHM_ID); } diff --git a/src/central-server/admin-service/core/src/test/java/org/niis/xroad/cs/admin/core/service/TimestampingServicesServiceImplTest.java b/src/central-server/admin-service/core/src/test/java/org/niis/xroad/cs/admin/core/service/TimestampingServicesServiceImplTest.java index 0c7a63673c..9c89cc6b84 100644 --- a/src/central-server/admin-service/core/src/test/java/org/niis/xroad/cs/admin/core/service/TimestampingServicesServiceImplTest.java +++ b/src/central-server/admin-service/core/src/test/java/org/niis/xroad/cs/admin/core/service/TimestampingServicesServiceImplTest.java @@ -115,7 +115,8 @@ void add() throws Exception { verify(auditDataHelper).put(TSA_ID, ID); verify(auditDataHelper).put(TSA_NAME, NAME); verify(auditDataHelper).put(TSA_URL, URL); - verify(auditDataHelper).put(TSA_CERT_HASH, "05:A1:0E:EB:DB:0C:D9:67:9E:4C:85:A7:88:48:14:5E:F1:F0:0B:EA"); + verify(auditDataHelper).put(TSA_CERT_HASH, + "09:4D:62:D7:5E:CC:25:D6:BD:9E:A8:3C:7B:34:67:80:16:BB:72:BB:80:11:8F:F6:EC:7E:4D:38:3A:67:8C:D1"); verify(auditDataHelper).put(TSA_CERT_HASH_ALGORITHM, DEFAULT_CERT_HASH_ALGORITHM_ID); } @@ -139,7 +140,8 @@ void update() throws Exception { verify(auditDataHelper).put(TSA_ID, ID); verify(auditDataHelper).put(TSA_NAME, NAME); verify(auditDataHelper).put(TSA_URL, request.getUrl()); - verify(auditDataHelper).put(TSA_CERT_HASH, "05:A1:0E:EB:DB:0C:D9:67:9E:4C:85:A7:88:48:14:5E:F1:F0:0B:EA"); + verify(auditDataHelper).put(TSA_CERT_HASH, + "09:4D:62:D7:5E:CC:25:D6:BD:9E:A8:3C:7B:34:67:80:16:BB:72:BB:80:11:8F:F6:EC:7E:4D:38:3A:67:8C:D1"); verify(auditDataHelper).put(TSA_CERT_HASH_ALGORITHM, DEFAULT_CERT_HASH_ALGORITHM_ID); } diff --git a/src/central-server/admin-service/globalconf-generator/src/main/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParameters.java b/src/central-server/admin-service/globalconf-generator/src/main/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParameters.java index 06c25eec58..c885ab6a5c 100644 --- a/src/central-server/admin-service/globalconf-generator/src/main/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParameters.java +++ b/src/central-server/admin-service/globalconf-generator/src/main/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParameters.java @@ -111,7 +111,7 @@ public static class SecurityServer { private ClientId owner; private String serverCode; private String address; - private List authCertHashes; + private List authCerts; private List clients; } diff --git a/src/central-server/admin-service/globalconf-generator/src/main/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersLoader.java b/src/central-server/admin-service/globalconf-generator/src/main/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersLoader.java index bfae1d5f4a..8c9dfd7949 100644 --- a/src/central-server/admin-service/globalconf-generator/src/main/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersLoader.java +++ b/src/central-server/admin-service/globalconf-generator/src/main/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersLoader.java @@ -27,10 +27,8 @@ package org.niis.xroad.cs.admin.globalconf.generator; import ee.ria.xroad.common.identifier.ClientId; -import ee.ria.xroad.common.util.CryptoUtils; import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.niis.xroad.cs.admin.api.domain.AuthCert; import org.niis.xroad.cs.admin.api.domain.ConfigurationSigningKey; @@ -91,7 +89,7 @@ SharedParameters load() { private List getSources() { return configurationService.getNodeAddressesWithConfigurationSigningKeys().entrySet().stream() .map(this::toSource) - .collect(toList()); + .toList(); } private SharedParameters.ConfigurationSource toSource( @@ -121,7 +119,7 @@ private List getApprovedCAs() { var approvedCas = certificationServicesService.findAll(); return approvedCas.stream() .map(this::toApprovedCa) - .collect(toList()); + .toList(); } private SharedParameters.ApprovedCA toApprovedCa(CertificationService ca) { @@ -137,13 +135,13 @@ private SharedParameters.ApprovedCA toApprovedCa(CertificationService ca) { private List toCaInfos(List cas) { return cas.stream() .map(ca -> new SharedParameters.CaInfo(toOcspInfos(ca.getOcspResponders()), ca.getCaCertificate().getEncoded())) - .collect(toList()); + .toList(); } private List toOcspInfos(List ocspResponders) { return ocspResponders.stream() .map(this::toOcspInfo) - .collect(toList()); + .toList(); } private SharedParameters.OcspInfo toOcspInfo(OcspResponder ocsp) { @@ -153,7 +151,7 @@ private SharedParameters.OcspInfo toOcspInfo(OcspResponder ocsp) { private List getApprovedTSAs() { return timestampingServicesService.getTimestampingServices().stream() .map(tsa -> new SharedParameters.ApprovedTSA(tsa.getName(), tsa.getUrl(), tsa.getCertificate().getEncoded())) - .collect(toList()); + .toList(); } private List getMembers() { @@ -164,7 +162,7 @@ private List getMembers() { private List getSecurityServers() { return securityServerService.findAll().stream() .map(this::toSecurityServer) - .collect(toList()); + .toList(); } private SharedParameters.SecurityServer toSecurityServer(SecurityServer ss) { @@ -173,22 +171,16 @@ private SharedParameters.SecurityServer toSecurityServer(SecurityServer ss) { result.setAddress(ss.getAddress()); result.setServerCode(ss.getServerCode()); result.setClients(getSecurityServerClients(ss.getId())); - result.setAuthCertHashes(ss.getAuthCerts().stream() + result.setAuthCerts(ss.getAuthCerts().stream() .map(AuthCert::getCert) - .map(SharedParametersLoader::certHash) - .collect(toList())); + .toList()); return result; } private List getSecurityServerClients(int id) { return clientService.find(new ClientService.SearchParameters().setSecurityServerId(id)) - .stream().map(SharedParametersLoader::toClientId).collect(toList()); - - } + .stream().map(SharedParametersLoader::toClientId).toList(); - @SneakyThrows - private static byte[] certHash(byte[] cert) { - return CryptoUtils.certHash(cert); } private static ClientId toClientId(FlattenedSecurityServerClientView client) { @@ -201,7 +193,7 @@ private static ClientId toClientId(FlattenedSecurityServerClientView client) { private List getGlobalGroups() { return globalGroupService.findGlobalGroups().stream() .map(this::getGlobalGroup) - .collect(toList()); + .toList(); } private SharedParameters.GlobalGroup getGlobalGroup(GlobalGroup globalGroup) { @@ -220,7 +212,7 @@ private List getGroupMembers(String groupCode) { private SharedParameters.GlobalSettings getGlobalSettings() { var memberClasses = memberClassService.findAll().stream() .map(memberClass -> new SharedParameters.MemberClass(memberClass.getCode(), memberClass.getDescription())) - .collect(toList()); + .toList(); return new SharedParameters.GlobalSettings(memberClasses, systemParameterService.getOcspFreshnessSeconds()); } diff --git a/src/central-server/admin-service/globalconf-generator/src/main/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersV2Converter.java b/src/central-server/admin-service/globalconf-generator/src/main/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersV2Converter.java index eff6eacd63..a91d5a3864 100644 --- a/src/central-server/admin-service/globalconf-generator/src/main/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersV2Converter.java +++ b/src/central-server/admin-service/globalconf-generator/src/main/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersV2Converter.java @@ -35,8 +35,10 @@ import ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.SharedParametersTypeV2; import ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.SubsystemType; import ee.ria.xroad.common.identifier.ClientId; +import ee.ria.xroad.common.util.CryptoUtils; import jakarta.xml.bind.JAXBElement; +import lombok.SneakyThrows; import org.mapstruct.Context; import org.mapstruct.Mapper; import org.mapstruct.Mapping; @@ -48,8 +50,6 @@ import java.util.List; import java.util.Map; -import static java.util.stream.Collectors.toList; - @Mapper(uses = {ObjectFactory.class, MappingUtils.class}, unmappedTargetPolicy = ReportingPolicy.ERROR) abstract class SharedParametersV2Converter { public static final SharedParametersV2Converter INSTANCE = Mappers.getMapper(SharedParametersV2Converter.class); @@ -73,7 +73,7 @@ SharedParametersTypeV2 convert(SharedParameters sharedParameters) { @Mapping(source = "intermediateCAs", target = "intermediateCA") abstract ApprovedCATypeV2 convert(SharedParameters.ApprovedCA approvedCa); - @Mapping(source = "authCertHashes", target = "authCertHash") + @Mapping(source = "authCerts", target = "authCertHash", qualifiedByName = "toAuthCertHashes") @Mapping(source = "clients", target = "client", qualifiedByName = "clientsById") @Mapping(target = "owner", qualifiedByName = "clientById") abstract SecurityServerType convert(SharedParameters.SecurityServer securityServer, @Context Map clientMap); @@ -104,7 +104,19 @@ List> xmlClientIds(List clientIds, @Context Map OBJECT_FACTORY.createSecurityServerTypeClient(xmlClientId(clientId, clientMap))) - .collect(toList()); + .toList(); + } + + @Named("toAuthCertHashes") + protected List toAuthCertHashes(List authCerts) { + return authCerts.stream() + .map(this::toAuthCertHash) + .toList(); + } + + @SneakyThrows + private byte[] toAuthCertHash(byte[] authCert) { + return CryptoUtils.certSha1Hash(authCert); } private Map createClientIdMap(SharedParameters sharedParameters) { diff --git a/src/central-server/admin-service/globalconf-generator/src/main/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersV3Converter.java b/src/central-server/admin-service/globalconf-generator/src/main/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersV3Converter.java index f1b7987a5d..ecfdae7e60 100644 --- a/src/central-server/admin-service/globalconf-generator/src/main/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersV3Converter.java +++ b/src/central-server/admin-service/globalconf-generator/src/main/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersV3Converter.java @@ -37,8 +37,10 @@ import ee.ria.xroad.common.conf.globalconf.sharedparameters.v3.SharedParametersTypeV3; import ee.ria.xroad.common.conf.globalconf.sharedparameters.v3.SubsystemType; import ee.ria.xroad.common.identifier.ClientId; +import ee.ria.xroad.common.util.CryptoUtils; import jakarta.xml.bind.JAXBElement; +import lombok.SneakyThrows; import org.mapstruct.Context; import org.mapstruct.Mapper; import org.mapstruct.Mapping; @@ -50,8 +52,6 @@ import java.util.List; import java.util.Map; -import static java.util.stream.Collectors.toList; - @Mapper(uses = {ObjectFactory.class, MappingUtils.class}, unmappedTargetPolicy = ReportingPolicy.ERROR) abstract class SharedParametersV3Converter { @@ -82,7 +82,7 @@ abstract SharedParametersTypeV3 convert(SharedParameters sharedParameters, @Mapping(source = "intermediateCAs", target = "intermediateCA") abstract ApprovedCATypeV3 convert(SharedParameters.ApprovedCA approvedCa); - @Mapping(source = "authCertHashes", target = "authCertHash") + @Mapping(source = "authCerts", target = "authCertHash", qualifiedByName = "toAuthCertHashes") @Mapping(source = "clients", target = "client", qualifiedByName = "clientsById") @Mapping(target = "owner", qualifiedByName = "clientById") abstract SecurityServerType convert(SharedParameters.SecurityServer securityServer, @Context Map clientMap); @@ -113,7 +113,19 @@ List> xmlClientIds(List clientIds, @Context Map OBJECT_FACTORY.createSecurityServerTypeClient(xmlClientId(clientId, clientMap))) - .collect(toList()); + .toList(); + } + + @Named("toAuthCertHashes") + protected List toAuthCertHashes(List authCerts) { + return authCerts.stream() + .map(this::toAuthCertHash) + .toList(); + } + + @SneakyThrows + private byte[] toAuthCertHash(byte[] authCert) { + return CryptoUtils.certHash(authCert); } private Map createClientIdMap(SharedParameters sharedParameters) { diff --git a/src/central-server/admin-service/globalconf-generator/src/test/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersLoaderTest.java b/src/central-server/admin-service/globalconf-generator/src/test/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersLoaderTest.java index 2041d1129b..4a8b302a80 100644 --- a/src/central-server/admin-service/globalconf-generator/src/test/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersLoaderTest.java +++ b/src/central-server/admin-service/globalconf-generator/src/test/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersLoaderTest.java @@ -27,7 +27,6 @@ package org.niis.xroad.cs.admin.globalconf.generator; import ee.ria.xroad.common.identifier.ClientId; -import ee.ria.xroad.common.util.CryptoUtils; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -174,7 +173,7 @@ private void assertSecurityServers(SharedParameters parameters) { assertThat(ss.getServerCode()).isEqualTo(SECURITY_SERVER_CODE); assertThat(ss.getClients()).singleElement() .isEqualTo(ClientId.Conf.create(XROAD_INSTANCE, "CLASS", "M2", "S1")); - assertThat(ss.getAuthCertHashes()).singleElement().isEqualTo(CryptoUtils.certHash(SECURITY_SERVER_AUTH_CERT)); + assertThat(ss.getAuthCerts()).singleElement().isEqualTo(SECURITY_SERVER_AUTH_CERT); }); } diff --git a/src/central-server/admin-service/globalconf-generator/src/test/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersV2ConverterTest.java b/src/central-server/admin-service/globalconf-generator/src/test/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersV2ConverterTest.java index 1d8f0b424b..eed626742c 100644 --- a/src/central-server/admin-service/globalconf-generator/src/test/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersV2ConverterTest.java +++ b/src/central-server/admin-service/globalconf-generator/src/test/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersV2ConverterTest.java @@ -29,6 +29,7 @@ import ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.ObjectFactory; import ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.SharedParametersTypeV2; import ee.ria.xroad.common.identifier.ClientId; +import ee.ria.xroad.common.util.CryptoUtils; import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBElement; @@ -37,8 +38,10 @@ import lombok.extern.slf4j.Slf4j; import org.assertj.core.api.recursive.comparison.ComparingNormalizedFields; import org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration; +import org.bouncycastle.operator.OperatorCreationException; import org.junit.jupiter.api.Test; +import java.io.IOException; import java.io.StringWriter; import java.math.BigInteger; import java.util.List; @@ -52,6 +55,7 @@ @Slf4j class SharedParametersV2ConverterTest { + private static final Map FIELD_NAME_MAP = Map.ofEntries( entry("securityServer", "securityServers"), entry("approvedCA", "approvedCAs"), @@ -62,12 +66,12 @@ class SharedParametersV2ConverterTest { entry("subsystem", "subsystems"), entry("client", "clients"), entry("memberClass", "memberClasses"), - entry("authCertHash", "authCertHashes"), + entry("authCertHash", "authCerts"), entry("groupMember", "groupMembers") ); @Test - void shouldConvertAllFields() { + void shouldConvertAllFields() throws IOException, OperatorCreationException { var sharedParameters = getSharedParameters(); var xmlType = SharedParametersV2Converter.INSTANCE.convert(sharedParameters); @@ -75,6 +79,7 @@ void shouldConvertAllFields() { .withIntrospectionStrategy(compareRenamedFields()) .withIgnoredFields("securityServers.owner", "securityServers.clients", + "securityServers.authCerts", "members.id", "members.subsystems.id", "centralService" @@ -95,6 +100,8 @@ void shouldConvertAllFields() { .allFieldsSatisfy(Objects::nonNull); assertIdReferences(xmlType); + assertThat(xmlType.getSecurityServer().get(0).getAuthCertHash().get(0)) + .isEqualTo(CryptoUtils.certSha1Hash(sharedParameters.getSecurityServers().get(0).getAuthCerts().get(0))); } @Test @@ -191,7 +198,7 @@ private static SharedParameters.SecurityServer getSecurityServer() { securityServer.setServerCode("security-server-code"); securityServer.setAddress("security-server-address"); securityServer.setClients(List.of(subsystemId(memberId(), "SUB1"))); - securityServer.setAuthCertHashes(List.of("ss-auth-cert".getBytes(UTF_8))); + securityServer.setAuthCerts(List.of("ss-auth-cert".getBytes(UTF_8))); return securityServer; } diff --git a/src/central-server/admin-service/globalconf-generator/src/test/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersV3ConverterTest.java b/src/central-server/admin-service/globalconf-generator/src/test/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersV3ConverterTest.java index 3d9ab92a87..58bd7e6eea 100644 --- a/src/central-server/admin-service/globalconf-generator/src/test/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersV3ConverterTest.java +++ b/src/central-server/admin-service/globalconf-generator/src/test/java/org/niis/xroad/cs/admin/globalconf/generator/SharedParametersV3ConverterTest.java @@ -29,6 +29,7 @@ import ee.ria.xroad.common.conf.globalconf.sharedparameters.v3.ObjectFactory; import ee.ria.xroad.common.conf.globalconf.sharedparameters.v3.SharedParametersTypeV3; import ee.ria.xroad.common.identifier.ClientId; +import ee.ria.xroad.common.util.CryptoUtils; import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBElement; @@ -37,8 +38,10 @@ import lombok.extern.slf4j.Slf4j; import org.assertj.core.api.recursive.comparison.ComparingNormalizedFields; import org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration; +import org.bouncycastle.operator.OperatorCreationException; import org.junit.jupiter.api.Test; +import java.io.IOException; import java.io.StringWriter; import java.math.BigInteger; import java.util.List; @@ -66,12 +69,12 @@ class SharedParametersV3ConverterTest { entry("subsystem", "subsystems"), entry("client", "clients"), entry("memberClass", "memberClasses"), - entry("authCertHash", "authCertHashes"), + entry("authCertHash", "authCerts"), entry("groupMember", "groupMembers") ); @Test - void shouldConvertAllFields() { + void shouldConvertAllFields() throws IOException, OperatorCreationException { var sharedParameters = getSharedParameters(); var xmlType = SharedParametersV3Converter.INSTANCE.convert(sharedParameters); @@ -79,6 +82,7 @@ void shouldConvertAllFields() { .withIntrospectionStrategy(compareRenamedFields()) .withIgnoredFields("securityServers.owner", "securityServers.clients", + "securityServers.authCerts", "members.id", "members.subsystems.id", "centralService", @@ -101,6 +105,8 @@ void shouldConvertAllFields() { .allFieldsSatisfy(Objects::nonNull); assertIdReferences(xmlType); + assertThat(xmlType.getSecurityServer().get(0).getAuthCertHash().get(0)) + .isEqualTo(CryptoUtils.certHash(sharedParameters.getSecurityServers().get(0).getAuthCerts().get(0))); } @Test @@ -209,7 +215,7 @@ private static SharedParameters.SecurityServer getSecurityServer() { securityServer.setServerCode("security-server-code"); securityServer.setAddress("security-server-address"); securityServer.setClients(List.of(subsystemId(memberId(), "SUB1"))); - securityServer.setAuthCertHashes(List.of("ss-auth-cert".getBytes(UTF_8))); + securityServer.setAuthCerts(List.of("ss-auth-cert".getBytes(UTF_8))); return securityServer; } diff --git a/src/central-server/admin-service/ui/src/components/certificate/CertificateHash.vue b/src/central-server/admin-service/ui/src/components/certificate/CertificateHash.vue index 796646da9f..d1ddfebcae 100644 --- a/src/central-server/admin-service/ui/src/components/certificate/CertificateHash.vue +++ b/src/central-server/admin-service/ui/src/components/certificate/CertificateHash.vue @@ -48,7 +48,7 @@ export default defineComponent({