From 6dd948c828405f72ae7685485ad64c64162bdc54 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Fri, 18 Dec 2020 06:58:18 -0500 Subject: [PATCH] Added a null check for the endorsement credential for the tpm 1.2 --- .../AbstractAttestationCertificateAuthority.java | 8 ++------ .../attestationca/IssuedCertificateAttributeHelper.java | 3 +++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/AbstractAttestationCertificateAuthority.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/AbstractAttestationCertificateAuthority.java index 874157a7..353d7564 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/AbstractAttestationCertificateAuthority.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/AbstractAttestationCertificateAuthority.java @@ -1263,12 +1263,8 @@ public abstract class AbstractAttestationCertificateAuthority Extension authKeyIdentifier = null; - try { - authKeyIdentifier = IssuedCertificateAttributeHelper - .buildAuthorityKeyIdentifier(endorsementCredential); - } catch (Exception ex) { - LOG.error("Test"); - } + authKeyIdentifier = IssuedCertificateAttributeHelper + .buildAuthorityKeyIdentifier(endorsementCredential); builder.addExtension(subjectAlternativeName); if (authKeyIdentifier != null) { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/IssuedCertificateAttributeHelper.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/IssuedCertificateAttributeHelper.java index 1e1f27ea..8a642133 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/IssuedCertificateAttributeHelper.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/IssuedCertificateAttributeHelper.java @@ -76,6 +76,9 @@ public final class IssuedCertificateAttributeHelper { */ public static Extension buildAuthorityKeyIdentifier( final EndorsementCredential endorsementCredential) throws IOException { + if (endorsementCredential == null || endorsementCredential.getX509Certificate() == null) { + return null; + } byte[] extValue = endorsementCredential.getX509Certificate() .getExtensionValue(Extension.authorityKeyIdentifier.getId());