Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions development/hurl/scenarios/setup.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ X-XSRF-TOKEN: {{cs_xsrf_token}}
[MultipartFormData]
certificate_profile_info: ee.ria.xroad.common.certificateprofile.impl.FiVRKCertificateProfileInfoProvider
tls_auth: false
default_csr_format: DER
acme_server_directory_url: http://{{ca_host}}:8887
certificate: file,ca/ca.pem;

Expand Down
398 changes: 199 additions & 199 deletions doc/DataModels/dm-cs_x-road_central_server_configuration_data_model.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ public CertificationService add(ApprovedCertificationService certificationServic
final var approvedCaEntity = new ApprovedCaEntity();
approvedCaEntity.setCertProfileInfo(certificationService.getCertificateProfileInfo());
approvedCaEntity.setAuthenticationOnly(certificationService.getTlsAuth());
if (certificationService.getDefaultCsrFormat() != null) {
approvedCaEntity.setDefaultCsrFormat(certificationService.getDefaultCsrFormat().name());
}
approvedCaEntity.setDefaultCsrFormat(certificationService.getDefaultCsrFormat().name());
X509Certificate certificate = handledCertificationChainRead(certificationService.getCertificate());
approvedCaEntity.setName(CertUtils.getSubjectCommonName(certificate));
approvedCaEntity.setAcmeServerDirectoryUrl(certificationService.getAcmeServerDirectoryUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,21 @@ public class CertificationServicesController implements CertificationServicesApi
@PreAuthorize("hasAuthority('ADD_APPROVED_CA')")
@AuditEventMethod(event = ADD_CERTIFICATION_SERVICE)
public ResponseEntity<ApprovedCertificationServiceDto> addCertificationService(MultipartFile certificate,
CsrFormatDto defaultCsrFormat,
String certificateProfileInfo,
String tlsAuth,
CsrFormatDto defaultCsrFormat,
String acmeServerDirectoryUrl,
String acmeServerIpAddress,
String authenticationCertificateProfileId,
String signingCertificateProfileId) {
var isForTlsAuth = parseBoolean(tlsAuth);
CsrFormat csrFormat = defaultCsrFormat != null
? CsrFormat.valueOf(defaultCsrFormat.name())
: CsrFormat.DER;
byte[] fileBytes = MultipartFileUtils.readBytes(certificate);
fileVerifier.validateCertificate(certificate.getOriginalFilename(), fileBytes);
var approvedCa = new ApprovedCertificationService(
fileBytes,
certificateProfileInfo,
isForTlsAuth,
csrFormat,
CsrFormat.valueOf(defaultCsrFormat.name()),
acmeServerDirectoryUrl,
acmeServerIpAddress,
authenticationCertificateProfileId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<include file="centerui/202504241111-security-server-maintenance-mode.xml" relativeToChangelogFile="true"/>
<include file="centerui/202510141700-tsa-ocsp-cost-type.xml" relativeToChangelogFile="true"/>
<include file="centerui/202511031700-ca-csr-format.xml" relativeToChangelogFile="true"/>
<include file="centerui/202511271200-ca-csr-nullable.xml" relativeToChangelogFile="true"/>

<!-- must be the last one -->
<changeSet id="separate-admin-user" author="niis" context="admin" runAlways="true" runOnChange="true" runOrder="last">
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a change to an unreleased version, I wonder if it would make more sense to just modify the original changelog file. This change will otherwise look strange in the actual production version, since we will have a changelog file that adds the column as not nullable and then in the same version upgrade do this change to make it nullable.

It will potentially create some issues in the future (e.g. upgrading the open beta environment we use for the security audit) and potentially for local development environments, but I feel would make the resulting software package clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about potentially doing it that way as well, however, liquibase themselves recommend not changing any already commited changelogs and instead do a "roll-forward", which means adding a new changelog to achieve the same result - https://www.liquibase.com/blog/dealing-with-changing-changesets

Since liquibase's update will fail if the database already has a changed changelog applied to it, this seems like the safest way to revert this non-nullable requirement.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd"
logicalFilePath="centerui/202511271200-ca-csr-nullable.xml">

<changeSet author="marc.david" id="202511271200-ca-csr-nullable">
<comment>Make default_csr_format nullable and remove default value.</comment>

<dropDefaultValue
tableName="approved_cas"
columnName="default_csr_format"
columnDataType="VARCHAR(255)"/>

<dropNotNullConstraint
tableName="approved_cas"
columnName="default_csr_format"
columnDataType="VARCHAR(255)"/>

<update tableName="approved_cas">
<column name="default_csr_format" valueComputed="NULL"/>
</update>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.niis.xroad.cs.openapi.model.ApprovedCertificationServiceDto;
import org.niis.xroad.cs.openapi.model.CertificationServiceSettingsDto;
import org.niis.xroad.cs.openapi.model.CostTypeDto;
import org.niis.xroad.cs.openapi.model.CsrFormatDto;
import org.niis.xroad.cs.openapi.model.OcspResponderDto;
import org.niis.xroad.cs.test.api.FeignCertificationServicesApi;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -177,13 +178,35 @@ public void createCertificationService() throws Exception {
"ee.ria.xroad.common.certificateprofile.impl.FiVRKCertificateProfileInfoProvider");
}

@Step("Certification service with certificateProfileInfo {string} and no default csr format is created")
public void createCertificationServiceWithoutCsrFormat(String certificateProfileInfo) throws Exception {
MultipartFile certificate = new MockMultipartFile("certificate", "certificate.cer", null, generateAuthCert("CN=" + "Subject"));

try {
final ResponseEntity<ApprovedCertificationServiceDto> result = certificationServicesApi
.addCertificationService(certificate, null, certificateProfileInfo, null, null, null, null, null);

validate(result)
.assertion(equalsStatusCodeAssertion(CREATED))
.assertion(notNullAssertion("body.id"))
.execute();

putStepData(CERTIFICATION_SERVICE_ID, result.getBody().getId());
putStepData(RESPONSE, result);
putStepData(RESPONSE_STATUS, result.getStatusCode().value());
} catch (FeignException feignException) {
putStepData(RESPONSE_STATUS, feignException.status());
putStepData(ERROR_RESPONSE_BODY, feignException.contentUTF8());
}
}

@Step("Certification service with name {string} and certificateProfileInfo {string} is created")
public void createCertificationService(String name, String certificateProfileInfo) throws Exception {
MultipartFile certificate = new MockMultipartFile("certificate", "certificate.cer", null, generateAuthCert("CN=" + name));

try {
final ResponseEntity<ApprovedCertificationServiceDto> result = certificationServicesApi
.addCertificationService(certificate, certificateProfileInfo, null, null, null, null, null, null);
.addCertificationService(certificate, CsrFormatDto.DER, certificateProfileInfo, null, null, null, null, null);

validate(result)
.assertion(equalsStatusCodeAssertion(CREATED))
Expand All @@ -204,7 +227,8 @@ public void createCertificationService(Integer id, String tlsAuth, String certif
try {
var request = new CertificationServiceSettingsDto()
.tlsAuth(tlsAuth)
.certificateProfileInfo(certificateProfileInfo);
.certificateProfileInfo(certificateProfileInfo)
.defaultCsrFormat(CsrFormatDto.DER);

final ResponseEntity<ApprovedCertificationServiceDto> result = certificationServicesApi
.updateCertificationService(id, request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ Feature: Certification services API
When Certification service with id 1 is updated with tlsAuth true and certificateProfileInfo "ee.ria.xroad.common.certificateprofile.impl.FiVRKCertificateProfileInfoProvider"
Then Returned certification service has id 1, tlsAuth true and certificateProfileInfo "ee.ria.xroad.common.certificateprofile.impl.FiVRKCertificateProfileInfoProvider"

Scenario: Certification Service is created and fails due to missing default_csr_format field
Given Authentication header is set to SYSTEM_ADMINISTRATOR
And Certification service with certificateProfileInfo "ee.ria.xroad.common.certificateprofile.impl.BasicCertificateProfileInfoProvider" and no default csr format is created
Then Response is of status code 400

@Modifying
Scenario Outline: Certification Service update failed
Given Authentication header is set to SYSTEM_ADMINISTRATOR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3547,6 +3547,9 @@ components:
- $ref: '#/components/schemas/CertificationServiceSettings'
description: certification service file and settings
type: object
required:
- certificate
- default_csr_format
Comment on lines +3550 to +3552
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make sure to add this to the implementation notes field of the ticket so that we remember to mention this in the release notes as it is a breaking change to the Central Server API.

CertificationServiceSettings:
description: certification service settings
properties:
Expand Down
Loading