From 1867e00301e6d0036fbffd80bdf0e3bd6ffaa711 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Tue, 31 Oct 2023 10:48:37 -0400 Subject: [PATCH] Updated the Rim Validator to remove direct object parameters from the database and pass in the information the methods needed to function --- .../validation/FirmwareScvValidator.java | 31 +++++++++++-------- ...eferenceManifestDetailsPageController.java | 5 +-- .../utils/rim/ReferenceManifestValidator.java | 23 ++++++++------ 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/FirmwareScvValidator.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/FirmwareScvValidator.java index 65c3654c..068f4dd1 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/FirmwareScvValidator.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/FirmwareScvValidator.java @@ -90,7 +90,7 @@ public class FirmwareScvValidator extends SupplyChainCredentialValidator { // verify signatures ReferenceManifestValidator referenceManifestValidator = new ReferenceManifestValidator(); - referenceManifestValidator.setRim(baseReferenceManifest); + referenceManifestValidator.setRim(baseReferenceManifest.getRimBytes()); //Validate signing cert List allCerts = caCredentialRepository.findAll(); @@ -99,23 +99,28 @@ public class FirmwareScvValidator extends SupplyChainCredentialValidator { signingCert = cert; KeyStore keyStore = ValidationService.getCaChain(signingCert, caCredentialRepository); - if (referenceManifestValidator.validateXmlSignature(signingCert)) { - try { - if (!SupplyChainCredentialValidator.verifyCertificate( + try { + if (referenceManifestValidator.validateXmlSignature(signingCert.getX509Certificate().getPublicKey(), + signingCert.getSubjectKeyIdString(), signingCert.getEncodedPublicKey())) { + try { + if (!SupplyChainCredentialValidator.verifyCertificate( signingCert.getX509Certificate(), keyStore)) { - passed = false; + passed = false; + fwStatus = new AppraisalStatus(FAIL, + "Firmware validation failed: invalid certificate path."); + validationObject = baseReferenceManifest; + } + } catch (IOException ioEx) { + log.error("Error getting X509 cert from manager: " + ioEx.getMessage()); + } catch (SupplyChainValidatorException scvEx) { + log.error("Error validating cert against keystore: " + scvEx.getMessage()); fwStatus = new AppraisalStatus(FAIL, "Firmware validation failed: invalid certificate path."); - validationObject = baseReferenceManifest; } - } catch (IOException ioEx) { - log.error("Error getting X509 cert from manager: " + ioEx.getMessage()); - } catch (SupplyChainValidatorException scvEx) { - log.error("Error validating cert against keystore: " + scvEx.getMessage()); - fwStatus = new AppraisalStatus(FAIL, - "Firmware validation failed: invalid certificate path."); + break; } - break; + } catch (IOException ioEx) { + log.error("Error getting X509 cert from manager: " + ioEx.getMessage()); } } diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestDetailsPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestDetailsPageController.java index e57701af..d20a4a29 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestDetailsPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestDetailsPageController.java @@ -272,7 +272,7 @@ public class ReferenceManifestDetailsPageController extends PageController