Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-Enable Certificate Validity Time Checks #17225

Merged
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
11 changes: 5 additions & 6 deletions src/crypto/CHIPCryptoPALOpenSSL.cpp
Original file line number Diff line number Diff line change
@@ -1737,7 +1737,7 @@ CHIP_ERROR IsCertificateValidAtIssuance(const ByteSpan & referenceCertificate, c
ASN1_TIME * refNotBeforeTime = nullptr;
ASN1_TIME * tbeNotBeforeTime = nullptr;
ASN1_TIME * tbeNotAfterTime = nullptr;
// int result = 0;
int result = 0;

VerifyOrReturnError(!referenceCertificate.empty() && !toBeEvaluatedCertificate.empty(), CHIP_ERROR_INVALID_ARGUMENT);

@@ -1753,14 +1753,13 @@ CHIP_ERROR IsCertificateValidAtIssuance(const ByteSpan & referenceCertificate, c
tbeNotAfterTime = X509_get_notAfter(x509toBeEvaluatedCertificate);
VerifyOrExit(refNotBeforeTime && tbeNotBeforeTime && tbeNotAfterTime, error = CHIP_ERROR_INTERNAL);

// TODO: Handle PAA/PAI re-issue and enable below time validations
// result = ASN1_TIME_compare(refNotBeforeTime, tbeNotBeforeTime);
result = ASN1_TIME_compare(refNotBeforeTime, tbeNotBeforeTime);
// check if referenceCertificate is issued at or after tbeCertificate's notBefore timestamp
// VerifyOrExit(result >= 0, error = CHIP_ERROR_CERT_EXPIRED);
VerifyOrExit(result >= 0, error = CHIP_ERROR_CERT_EXPIRED);

// result = ASN1_TIME_compare(refNotBeforeTime, tbeNotAfterTime);
result = ASN1_TIME_compare(refNotBeforeTime, tbeNotAfterTime);
// check if referenceCertificate is issued at or before tbeCertificate's notAfter timestamp
// VerifyOrExit(result <= 0, error = CHIP_ERROR_CERT_EXPIRED);
VerifyOrExit(result <= 0, error = CHIP_ERROR_CERT_EXPIRED);

exit:
X509_free(x509ReferenceCertificate);
5 changes: 2 additions & 3 deletions src/crypto/CHIPCryptoPALmbedTLS.cpp
Original file line number Diff line number Diff line change
@@ -1403,12 +1403,11 @@ CHIP_ERROR IsCertificateValidAtIssuance(const ByteSpan & referenceCertificate, c
tbeNotBeforeTime = mbedToBeEvaluatedCertificate.CHIP_CRYPTO_PAL_PRIVATE_X509(valid_from);
tbeNotAfterTime = mbedToBeEvaluatedCertificate.CHIP_CRYPTO_PAL_PRIVATE_X509(valid_to);

// TODO: Handle PAA/PAI re-issue and enable below time validation
// check if referenceCertificate is issued at or after tbeCertificate's notBefore timestamp
// VerifyOrExit(IsTimeGreaterThanEqual(&refNotBeforeTime, &tbeNotBeforeTime), error = CHIP_ERROR_CERT_EXPIRED);
VerifyOrExit(IsTimeGreaterThanEqual(&refNotBeforeTime, &tbeNotBeforeTime), error = CHIP_ERROR_CERT_EXPIRED);

// check if referenceCertificate is issued at or before tbeCertificate's notAfter timestamp
// VerifyOrExit(IsTimeGreaterThanEqual(&tbeNotAfterTime, &refNotBeforeTime), error = CHIP_ERROR_CERT_EXPIRED);
VerifyOrExit(IsTimeGreaterThanEqual(&tbeNotAfterTime, &refNotBeforeTime), error = CHIP_ERROR_CERT_EXPIRED);

exit:
_log_mbedTLS_error(result);