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

Side by Side Diff: net/cert/cert_verify_proc.cc

Issue 20628006: Reject certificates that are valid for too long. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase?! In our moment of triumph?! Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « net/cert/cert_verify_proc.h ('k') | net/cert/cert_verify_proc_unittest.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/cert/cert_verify_proc.h" 5 #include "net/cert/cert_verify_proc.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/sha1.h" 8 #include "base/sha1.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/time/time.h"
10 #include "build/build_config.h" 11 #include "build/build_config.h"
11 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
12 #include "net/base/net_util.h" 13 #include "net/base/net_util.h"
13 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 14 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
14 #include "net/cert/cert_status_flags.h" 15 #include "net/cert/cert_status_flags.h"
15 #include "net/cert/cert_verifier.h" 16 #include "net/cert/cert_verifier.h"
16 #include "net/cert/cert_verify_result.h" 17 #include "net/cert/cert_verify_result.h"
17 #include "net/cert/crl_set.h" 18 #include "net/cert/crl_set.h"
18 #include "net/cert/x509_certificate.h" 19 #include "net/cert/x509_certificate.h"
19 #include "url/url_canon.h" 20 #include "url/url_canon.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // hosts. While the CA/Browser Forum Baseline Requirements (v1.1) permit 266 // hosts. While the CA/Browser Forum Baseline Requirements (v1.1) permit
266 // these to be issued until 1 November 2015, they represent a real risk for 267 // these to be issued until 1 November 2015, they represent a real risk for
267 // the deployment of gTLDs and are being phased out ahead of the hard 268 // the deployment of gTLDs and are being phased out ahead of the hard
268 // deadline. 269 // deadline.
269 if (verify_result->is_issued_by_known_root && IsHostnameNonUnique(hostname)) { 270 if (verify_result->is_issued_by_known_root && IsHostnameNonUnique(hostname)) {
270 verify_result->cert_status |= CERT_STATUS_NON_UNIQUE_NAME; 271 verify_result->cert_status |= CERT_STATUS_NON_UNIQUE_NAME;
271 // CERT_STATUS_NON_UNIQUE_NAME will eventually become a hard error. For 272 // CERT_STATUS_NON_UNIQUE_NAME will eventually become a hard error. For
272 // now treat it as a warning and do not map it to an error return value. 273 // now treat it as a warning and do not map it to an error return value.
273 } 274 }
274 275
276 // Flag certificates using too long validity periods.
277 if (HasTooLongValidity(*cert)) {
Ryan Sleevi 2014/10/27 22:07:39 Remind me why we aren't checking is_issued_by_know
palmer 2014/10/28 00:05:53 Done.
278 verify_result->cert_status |= CERT_STATUS_TOO_LONG_VALIDITY;
279 if (rv == OK)
280 rv = MapCertStatusToNetError(verify_result->cert_status);
281 }
282
275 return rv; 283 return rv;
276 } 284 }
277 285
278 // static 286 // static
279 bool CertVerifyProc::IsBlacklisted(X509Certificate* cert) { 287 bool CertVerifyProc::IsBlacklisted(X509Certificate* cert) {
280 static const unsigned kComodoSerialBytes = 16; 288 static const unsigned kComodoSerialBytes = 16;
281 static const uint8 kComodoSerials[][kComodoSerialBytes] = { 289 static const uint8 kComodoSerials[][kComodoSerialBytes] = {
282 // Not a real certificate. For testing only. 290 // Not a real certificate. For testing only.
283 {0x07,0x7a,0x59,0xbc,0xd5,0x34,0x59,0x60,0x1c,0xa6,0x90,0x72,0x67,0xa6,0xdd, 0x1c}, 291 {0x07,0x7a,0x59,0xbc,0xd5,0x34,0x59,0x60,0x1c,0xa6,0x90,0x72,0x67,0xa6,0xdd, 0x1c},
284 292
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 if (!CheckNameConstraints(dns_names, kLimits[i].tlds)) 533 if (!CheckNameConstraints(dns_names, kLimits[i].tlds))
526 return true; 534 return true;
527 } 535 }
528 } 536 }
529 } 537 }
530 } 538 }
531 539
532 return false; 540 return false;
533 } 541 }
534 542
543 // static
544 bool CertVerifyProc::HasTooLongValidity(const X509Certificate& cert) {
545 base::Time::Exploded start;
546 base::Time::Exploded expiry;
547 cert.valid_start().UTCExplode(&start);
548 cert.valid_expiry().UTCExplode(&expiry);
Ryan Sleevi 2014/10/27 22:07:39 Note that both of these can fail for some certific
palmer 2014/10/28 00:05:53 Done for a first pass. My immediate goal is to re-
549 int month_diff =
550 expiry.year * 12 + expiry.month - start.year * 12 - start.month;
551 // Add any remainder as a full month.
552 if (expiry.day_of_month > start.day_of_month)
553 ++month_diff;
554
555 static const base::Time time_2015_04_01 = base::Time::FromInternalValue(
556 GG_INT64_C(1427871600));
557 static const base::Time time_2012_07_01 = base::Time::FromInternalValue(
558 GG_INT64_C(1341126000));
559 static const base::Time time_2019_07_01 = base::Time::FromInternalValue(
560 GG_INT64_C(1561964400));
561
562 if (cert.valid_start() >= time_2015_04_01)
563 return month_diff > 39;
564 if (cert.valid_start() >= time_2012_07_01)
565 return month_diff > 60;
566 return month_diff > 120 || cert.valid_expiry() > time_2019_07_01;
567 }
568
535 } // namespace net 569 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/cert_verify_proc.h ('k') | net/cert/cert_verify_proc_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698