Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Unified Diff: net/cert/internal/verify_certificate_chain_pkits_unittest.cc

Issue 1976433002: Add new ParsedCertificate class, move TrustStore to own file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert-parsing-remove-old-parsedcertificate
Patch Set: more comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/cert/internal/verify_certificate_chain_pkits_unittest.cc
diff --git a/net/cert/internal/verify_certificate_chain_pkits_unittest.cc b/net/cert/internal/verify_certificate_chain_pkits_unittest.cc
index 606563708ae98da1df7bc8e0412616eb28a0d9df..1a2fc789713d59518c116d7c21d65e17111dfadd 100644
--- a/net/cert/internal/verify_certificate_chain_pkits_unittest.cc
+++ b/net/cert/internal/verify_certificate_chain_pkits_unittest.cc
@@ -4,8 +4,9 @@
#include "net/cert/internal/verify_certificate_chain.h"
-#include "net/cert/internal/parse_certificate.h"
+#include "net/cert/internal/parsed_certificate.h"
#include "net/cert/internal/signature_policy.h"
+#include "net/cert/internal/trust_store.h"
#include "net/der/input.h"
// Disable tests that require DSA signatures (DSA signatures are intentionally
@@ -53,13 +54,25 @@ class VerifyCertificateChainPkitsTestDelegate {
}
// First entry in the PKITS chain is the trust anchor.
TrustStore trust_store;
- EXPECT_TRUE(trust_store.AddTrustedCertificate(cert_ders[0]));
+ scoped_refptr<ParsedCertificate> anchor(
+ ParsedCertificate::CreateFromCertificateCopy(cert_ders[0]));
+ EXPECT_TRUE(anchor);
+ if (anchor)
+ trust_store.AddTrustedCertificate(std::move(anchor));
// PKITS lists chains from trust anchor to target, VerifyCertificateChain
// takes them starting with the target and not including the trust anchor.
- std::vector<der::Input> input_chain;
- for (size_t i = cert_ders.size() - 1; i > 0; --i)
- input_chain.push_back(der::Input(&cert_ders[i]));
+ std::vector<scoped_refptr<net::ParsedCertificate>> input_chain;
+ for (size_t i = cert_ders.size() - 1; i > 0; --i) {
+ if (!net::ParsedCertificate::CreateAndAddToVector(
+ reinterpret_cast<const uint8_t*>(cert_ders[i].data()),
+ cert_ders[i].size(),
+ net::ParsedCertificate::DataSource::EXTERNAL_REFERENCE,
+ &input_chain)) {
+ ADD_FAILURE() << "cert " << i << " failed to parse";
+ return false;
+ }
+ }
SimpleSignaturePolicy signature_policy(1024);

Powered by Google App Engine
This is Rietveld 408576698