Skip to content

Commit

Permalink
Add Validation of TrustAnchor OR Upload and CSCA Certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
f11h committed Mar 8, 2022
1 parent 2e33053 commit 1a38da3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ boolean checkTrustAnchorSignature(TrustedIssuerDto trustedIssuer, List<X509Certi
return trustAnchors.stream().anyMatch(trustAnchor -> parser.getSigningCertificate().equals(trustAnchor));
}

boolean checkTrustAnchorSignature(TrustedCertificateTrustListDto trustedCertificate) {
return checkTrustAnchorSignature(trustedCertificateMapper.mapToTrustList(trustedCertificate), trustAnchors);
}

X509CertificateHolder getCertificateFromTrustListItem(TrustListItem trustListItem) {
byte[] decodedBytes = Base64.getDecoder().decode(trustListItem.getRawData());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private synchronized void updateIfRequired() {

if (properties.isEnableDdccSupport()) {
// Fetching TrustedCertificates
fetchTrustedCertificatesAndVerifyByCscaAndUpload();
fetchTrustedCertificatesAndVerifyByTrustAnchorOrCscaAndUpload();

// Fetching TrustedIssuers
trustedIssuers = connectorUtils.fetchTrustedIssuersAndVerifyByTrustAnchor(queryParameterMap);
Expand Down Expand Up @@ -325,7 +325,7 @@ private void fetchTrustListAndVerifyByCscaAndUpload() throws DgcGatewayConnector
log.info("Put {} trusted certificates into TrustList", trustedCertificates.size());
}

private void fetchTrustedCertificatesAndVerifyByCscaAndUpload() throws
private void fetchTrustedCertificatesAndVerifyByTrustAnchorOrCscaAndUpload() throws
DgcGatewayConnectorUtils.DgcGatewayConnectorException {
if (!properties.isEnableDdccSupport()) {
log.info("DDCC Support is disabled, Skipping TrustedCertificate Download.");
Expand All @@ -351,8 +351,8 @@ private void fetchTrustedCertificatesAndVerifyByCscaAndUpload() throws
}

ddccTrustedCertificates = responseEntity.getBody().stream()
.filter(this::checkCscaCertificate)
.filter(this::checkUploadCertificate)
.filter(cert -> (connectorUtils.checkTrustAnchorSignature(cert)
|| (checkCscaCertificate(cert) && checkUploadCertificate(cert))))
.map(trustedCertificateMapper::map)
.collect(Collectors.toList());

Expand Down

0 comments on commit 1a38da3

Please sign in to comment.