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

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

Issue 2292333002: Add errors per ResultPath for CertPathBuilder. (Closed)
Patch Set: remove error for null trust anchor Created 4 years, 3 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 | « components/cast_certificate/cast_cert_validator.cc ('k') | net/cert/internal/path_builder.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_crl.h" 5 #include "components/cast_certificate/cast_crl.h"
6 6
7 #include <unordered_map> 7 #include <unordered_map>
8 #include <unordered_set> 8 #include <unordered_set>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 if (!net::der::EncodeTimeAsGeneralizedTime(time, &verification_time)) { 138 if (!net::der::EncodeTimeAsGeneralizedTime(time, &verification_time)) {
139 VLOG(2) << "CRL - Unable to parse verification time."; 139 VLOG(2) << "CRL - Unable to parse verification time.";
140 return false; 140 return false;
141 } 141 }
142 net::CertPathBuilder::Result result; 142 net::CertPathBuilder::Result result;
143 net::CertPathBuilder path_builder(parsed_cert.get(), trust_store, 143 net::CertPathBuilder path_builder(parsed_cert.get(), trust_store,
144 signature_policy.get(), verification_time, 144 signature_policy.get(), verification_time,
145 &result); 145 &result);
146 net::CompletionStatus rv = path_builder.Run(base::Closure()); 146 net::CompletionStatus rv = path_builder.Run(base::Closure());
147 DCHECK_EQ(rv, net::CompletionStatus::SYNC); 147 DCHECK_EQ(rv, net::CompletionStatus::SYNC);
148 if (!result.is_success() || result.paths.empty() || 148 if (!result.HasValidPath()) {
149 !result.paths[result.best_result_index]->is_success()) {
150 VLOG(2) << "CRL - Issuer certificate verification failed."; 149 VLOG(2) << "CRL - Issuer certificate verification failed.";
150 // TODO(crbug.com/634443): Log the error information.
151 return false; 151 return false;
152 } 152 }
153 // There are no requirements placed on the leaf certificate having any 153 // There are no requirements placed on the leaf certificate having any
154 // particular KeyUsages. Leaf certificate checks are bypassed. 154 // particular KeyUsages. Leaf certificate checks are bypassed.
155 155
156 // Verify the CRL is still valid. 156 // Verify the CRL is still valid.
157 net::der::GeneralizedTime not_before; 157 net::der::GeneralizedTime not_before;
158 if (!ConvertTimeSeconds(tbs_crl.not_before_seconds(), &not_before)) { 158 if (!ConvertTimeSeconds(tbs_crl.not_before_seconds(), &not_before)) {
159 VLOG(2) << "CRL - Unable to parse not_before."; 159 VLOG(2) << "CRL - Unable to parse not_before.";
160 return false; 160 return false;
161 } 161 }
162 net::der::GeneralizedTime not_after; 162 net::der::GeneralizedTime not_after;
163 if (!ConvertTimeSeconds(tbs_crl.not_after_seconds(), &not_after)) { 163 if (!ConvertTimeSeconds(tbs_crl.not_after_seconds(), &not_after)) {
164 VLOG(2) << "CRL - Unable to parse not_after."; 164 VLOG(2) << "CRL - Unable to parse not_after.";
165 return false; 165 return false;
166 } 166 }
167 if ((verification_time < not_before) || (verification_time > not_after)) { 167 if ((verification_time < not_before) || (verification_time > not_after)) {
168 VLOG(2) << "CRL - Not time-valid."; 168 VLOG(2) << "CRL - Not time-valid.";
169 return false; 169 return false;
170 } 170 }
171 171
172 // Set CRL expiry to the earliest of the cert chain expiry and CRL expiry. 172 // Set CRL expiry to the earliest of the cert chain expiry and CRL expiry.
173 // Note that the trust anchor is not part of this loop. 173 // Note that the trust anchor is not part of this loop.
174 // "expiration" of the trust anchor is handled instead by its 174 // "expiration" of the trust anchor is handled instead by its
175 // presence in the trust store. 175 // presence in the trust store.
176 *overall_not_after = not_after; 176 *overall_not_after = not_after;
177 for (const auto& cert : result.paths[result.best_result_index]->path.certs) { 177 for (const auto& cert : result.GetBestValidPath()->path.certs) {
178 net::der::GeneralizedTime cert_not_after = cert->tbs().validity_not_after; 178 net::der::GeneralizedTime cert_not_after = cert->tbs().validity_not_after;
179 if (cert_not_after < *overall_not_after) 179 if (cert_not_after < *overall_not_after)
180 *overall_not_after = cert_not_after; 180 *overall_not_after = cert_not_after;
181 } 181 }
182 182
183 // Perform sanity check on serial numbers. 183 // Perform sanity check on serial numbers.
184 for (const auto& range : tbs_crl.revoked_serial_number_ranges()) { 184 for (const auto& range : tbs_crl.revoked_serial_number_ranges()) {
185 uint64_t first_serial_number = range.first_serial_number(); 185 uint64_t first_serial_number = range.first_serial_number();
186 uint64_t last_serial_number = range.last_serial_number(); 186 uint64_t last_serial_number = range.last_serial_number();
187 if (last_serial_number < first_serial_number) { 187 if (last_serial_number < first_serial_number) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 } 352 }
353 353
354 std::unique_ptr<CastCRL> ParseAndVerifyCRLForTest( 354 std::unique_ptr<CastCRL> ParseAndVerifyCRLForTest(
355 const std::string& crl_proto, 355 const std::string& crl_proto,
356 const base::Time& time, 356 const base::Time& time,
357 net::TrustStore* trust_store) { 357 net::TrustStore* trust_store) {
358 return ParseAndVerifyCRL(crl_proto, time, trust_store); 358 return ParseAndVerifyCRL(crl_proto, time, trust_store);
359 } 359 }
360 360
361 } // namespace cast_certificate 361 } // namespace cast_certificate
OLDNEW
« no previous file with comments | « components/cast_certificate/cast_cert_validator.cc ('k') | net/cert/internal/path_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698