Skip to content

Commit

Permalink
[iam] Fix to return new certificate for empty serial
Browse files Browse the repository at this point in the history
Signed-off-by: Mykola Kobets <[email protected]>
  • Loading branch information
mykola-kobets-epam committed Oct 3, 2024
1 parent 272ce03 commit 218e614
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/iam/certmodules/certmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Error CertModule::GetCertificate(const Array<uint8_t>& issuer, const Array<uint8

resCert = {};
for (const auto& item : *certsInStorage) {
if (resCert.mNotAfter.IsZero() || item.mNotAfter < resCert.mNotAfter) {
if (resCert.mNotAfter.IsZero() || resCert.mNotAfter < item.mNotAfter) {
resCert = item;
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/iam/iam_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,13 @@ TEST_F(IAMTest, GetCertificateEmptySerial)
ASSERT_TRUE(mStorage.GetCertsInfo("iam", storageCerts).IsNone());
ASSERT_EQ(storageCerts.Size(), 2);

// check GetCertificate returns certificate with minimal mNotAfter
// check GetCertificate returns certificate with max mNotAfter
CertInfo certInfo;

const auto empty = Array<uint8_t>(nullptr, 0);

ASSERT_TRUE(mCertHandler->GetCertificate("iam", empty, empty, certInfo).IsNone());
ASSERT_EQ(certInfo, storageCerts[0]);
ASSERT_EQ(certInfo, storageCerts[1]);
}

TEST_F(IAMTest, SubscribeCertReceiver)
Expand Down

0 comments on commit 218e614

Please sign in to comment.