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

Side by Side Diff: components/cast_certificate/cast_cert_validator.cc

Issue 2225493003: Don't treat trust anchors as certificates during path building. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address moar feedback Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/cast_certificate/cast_crl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/cast_certificate/cast_cert_validator.h" 5 #include "components/cast_certificate/cast_cert_validator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 CastTrustStore() { 61 CastTrustStore() {
62 AddAnchor(kCastRootCaDer); 62 AddAnchor(kCastRootCaDer);
63 AddAnchor(kEurekaRootCaDer); 63 AddAnchor(kEurekaRootCaDer);
64 } 64 }
65 65
66 // Adds a trust anchor given a DER-encoded certificate from static 66 // Adds a trust anchor given a DER-encoded certificate from static
67 // storage. 67 // storage.
68 template <size_t N> 68 template <size_t N>
69 void AddAnchor(const uint8_t (&data)[N]) { 69 void AddAnchor(const uint8_t (&data)[N]) {
70 scoped_refptr<net::ParsedCertificate> root = 70 scoped_refptr<net::ParsedCertificate> cert =
71 net::ParsedCertificate::CreateFromCertificateData( 71 net::ParsedCertificate::CreateFromCertificateData(
72 data, N, net::ParsedCertificate::DataSource::EXTERNAL_REFERENCE, 72 data, N, net::ParsedCertificate::DataSource::EXTERNAL_REFERENCE,
73 {}); 73 {});
74 CHECK(root); 74 CHECK(cert);
75 store_.AddTrustedCertificate(std::move(root)); 75 // TODO(crbug.com/635200): Support anchor constraints, and initialize the
76 // anchor using constraints from the self-signed certificate.
77 scoped_refptr<net::TrustAnchor> anchor =
78 net::TrustAnchor::CreateFromCertificateNoConstraints(std::move(cert));
79 store_.AddTrustAnchor(std::move(anchor));
76 } 80 }
77 81
78 net::TrustStore store_; 82 net::TrustStore store_;
79 DISALLOW_COPY_AND_ASSIGN(CastTrustStore); 83 DISALLOW_COPY_AND_ASSIGN(CastTrustStore);
80 }; 84 };
81 85
82 using ExtensionsMap = std::map<net::der::Input, net::ParsedExtension>; 86 using ExtensionsMap = std::map<net::der::Input, net::ParsedExtension>;
83 87
84 // Helper that looks up an extension by OID given a map of extensions. 88 // Helper that looks up an extension by OID given a map of extensions.
85 bool GetExtensionValue(const ExtensionsMap& extensions, 89 bool GetExtensionValue(const ExtensionsMap& extensions,
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 351
348 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest( 352 std::unique_ptr<CertVerificationContext> CertVerificationContextImplForTest(
349 const base::StringPiece& spki) { 353 const base::StringPiece& spki) {
350 // Use a bogus CommonName, since this is just exposed for testing signature 354 // Use a bogus CommonName, since this is just exposed for testing signature
351 // verification by unittests. 355 // verification by unittests.
352 return base::WrapUnique( 356 return base::WrapUnique(
353 new CertVerificationContextImpl(net::der::Input(spki), "CommonName")); 357 new CertVerificationContextImpl(net::der::Input(spki), "CommonName"));
354 } 358 }
355 359
356 } // namespace cast_certificate 360 } // namespace cast_certificate
OLDNEW
« no previous file with comments | « no previous file | components/cast_certificate/cast_crl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698