| OLD | NEW |
| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 // Treat certificates signed using broken signature algorithms as invalid. | 469 // Treat certificates signed using broken signature algorithms as invalid. |
| 470 if (verify_result->has_md2 || verify_result->has_md4) { | 470 if (verify_result->has_md2 || verify_result->has_md4) { |
| 471 verify_result->cert_status |= CERT_STATUS_INVALID; | 471 verify_result->cert_status |= CERT_STATUS_INVALID; |
| 472 rv = MapCertStatusToNetError(verify_result->cert_status); | 472 rv = MapCertStatusToNetError(verify_result->cert_status); |
| 473 } | 473 } |
| 474 | 474 |
| 475 if (verify_result->has_sha1) | 475 if (verify_result->has_sha1) |
| 476 verify_result->cert_status |= CERT_STATUS_SHA1_SIGNATURE_PRESENT; | 476 verify_result->cert_status |= CERT_STATUS_SHA1_SIGNATURE_PRESENT; |
| 477 | 477 |
| 478 // Flag certificates using weak signature algorithms. | 478 // Flag certificates using weak signature algorithms. |
| 479 // The CA/Browser Forum Baseline Requirements (beginning with v1.2.1) | 479 |
| 480 // prohibits SHA-1 certificates from being issued beginning on | 480 // Legacy SHA-1 behaviour: |
| 481 // 1 January 2016. Ideally, all of SHA-1 in new certificates would be | 481 // - Reject all publicly trusted SHA-1 leaf certs issued after |
| 482 // disabled on this date, but enterprises need more time to transition. | 482 // 2016-01-01. |
| 483 // As the risk is greatest for publicly trusted certificates, prevent | 483 bool legacy_sha1_issue = verify_result->has_sha1_leaf && |
| 484 // those certificates from being trusted from that date forward. | 484 verify_result->is_issued_by_known_root && |
| 485 // | 485 IsPastSHA1DeprecationDate(*cert); |
| 486 // TODO(mattm): apply the SHA-1 deprecation check to all certs unless | 486 |
| 487 // CertVerifier::VERIFY_ENABLE_SHA1_LOCAL_ANCHORS flag is present. | 487 // Current SHA-1 behaviour: |
| 488 // - Reject all SHA-1 |
| 489 // - ... unless it's not publicly trusted and SHA-1 is allowed |
| 490 // - ... or SHA-1 is in the intermediate and SHA-1 intermediates are |
| 491 // allowed for that platform. See https://crbug.com/588789 |
| 492 bool current_sha1_issue = |
| 493 (verify_result->is_issued_by_known_root || |
| 494 !(flags & CertVerifier::VERIFY_ENABLE_SHA1_LOCAL_ANCHORS)) && |
| 495 (verify_result->has_sha1_leaf || |
| 496 (verify_result->has_sha1 && !AreSHA1IntermediatesAllowed())); |
| 497 |
| 488 if (verify_result->has_md5 || | 498 if (verify_result->has_md5 || |
| 489 // Current SHA-1 behaviour: | 499 (sha1_legacy_mode_enabled && legacy_sha1_issue) || |
| 490 // - Reject all publicly trusted SHA-1 | 500 (!sha1_legacy_mode_enabled && current_sha1_issue)) { |
| 491 // - ... unless it's in the intermediate and SHA-1 intermediates are | |
| 492 // allowed for that platform. See https://crbug.com/588789 | |
| 493 (!sha1_legacy_mode_enabled && | |
| 494 (verify_result->is_issued_by_known_root && | |
| 495 (verify_result->has_sha1_leaf || | |
| 496 (verify_result->has_sha1 && !AreSHA1IntermediatesAllowed())))) || | |
| 497 // Legacy SHA-1 behaviour: | |
| 498 // - Reject all publicly trusted SHA-1 leaf certs issued after | |
| 499 // 2016-01-01. | |
| 500 (sha1_legacy_mode_enabled && (verify_result->has_sha1_leaf && | |
| 501 verify_result->is_issued_by_known_root && | |
| 502 IsPastSHA1DeprecationDate(*cert)))) { | |
| 503 verify_result->cert_status |= CERT_STATUS_WEAK_SIGNATURE_ALGORITHM; | 501 verify_result->cert_status |= CERT_STATUS_WEAK_SIGNATURE_ALGORITHM; |
| 504 // Avoid replacing a more serious error, such as an OS/library failure, | 502 // Avoid replacing a more serious error, such as an OS/library failure, |
| 505 // by ensuring that if verification failed, it failed with a certificate | 503 // by ensuring that if verification failed, it failed with a certificate |
| 506 // error. | 504 // error. |
| 507 if (rv == OK || IsCertificateError(rv)) | 505 if (rv == OK || IsCertificateError(rv)) |
| 508 rv = MapCertStatusToNetError(verify_result->cert_status); | 506 rv = MapCertStatusToNetError(verify_result->cert_status); |
| 509 } | 507 } |
| 510 | 508 |
| 511 // Flag certificates from publicly-trusted CAs that are issued to intranet | 509 // Flag certificates from publicly-trusted CAs that are issued to intranet |
| 512 // hosts. While the CA/Browser Forum Baseline Requirements (v1.1) permit | 510 // hosts. While the CA/Browser Forum Baseline Requirements (v1.1) permit |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 return true; | 768 return true; |
| 771 | 769 |
| 772 return false; | 770 return false; |
| 773 } | 771 } |
| 774 | 772 |
| 775 // static | 773 // static |
| 776 const base::Feature CertVerifyProc::kSHA1LegacyMode{ | 774 const base::Feature CertVerifyProc::kSHA1LegacyMode{ |
| 777 "SHA1LegacyMode", base::FEATURE_DISABLED_BY_DEFAULT}; | 775 "SHA1LegacyMode", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 778 | 776 |
| 779 } // namespace net | 777 } // namespace net |
| OLD | NEW |