OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/internal/verify_certificate_chain.h" | 5 #include "net/cert/internal/verify_certificate_chain.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 "Certificate.signatureAlgorithm is encoded differently " | 57 "Certificate.signatureAlgorithm is encoded differently " |
58 "than TBSCertificate.signature"); | 58 "than TBSCertificate.signature"); |
59 DEFINE_CERT_ERROR_ID(kEkuLacksServerAuth, | 59 DEFINE_CERT_ERROR_ID(kEkuLacksServerAuth, |
60 "The extended key usage does not include server auth"); | 60 "The extended key usage does not include server auth"); |
61 DEFINE_CERT_ERROR_ID(kEkuLacksClientAuth, | 61 DEFINE_CERT_ERROR_ID(kEkuLacksClientAuth, |
62 "The extended key usage does not include client auth"); | 62 "The extended key usage does not include client auth"); |
63 | 63 |
64 bool IsHandledCriticalExtensionOid(const der::Input& oid) { | 64 bool IsHandledCriticalExtensionOid(const der::Input& oid) { |
65 if (oid == BasicConstraintsOid()) | 65 if (oid == BasicConstraintsOid()) |
66 return true; | 66 return true; |
| 67 // Key Usage is NOT processed for end-entity certificates (this is the |
| 68 // responsibility of callers), however it is considered "handled" here in |
| 69 // order to allow being marked as critical. |
67 if (oid == KeyUsageOid()) | 70 if (oid == KeyUsageOid()) |
68 return true; | 71 return true; |
69 if (oid == ExtKeyUsageOid()) | 72 if (oid == ExtKeyUsageOid()) |
70 return true; | 73 return true; |
71 if (oid == NameConstraintsOid()) | 74 if (oid == NameConstraintsOid()) |
72 return true; | 75 return true; |
73 // TODO(eroman): SubjectAltName isn't actually used here, but rather is being | |
74 // checked by a higher layer. | |
75 if (oid == SubjectAltNameOid()) | 76 if (oid == SubjectAltNameOid()) |
76 return true; | 77 return true; |
77 | 78 |
78 // TODO(eroman): Make this more complete. | 79 // TODO(eroman): Make this more complete. |
79 return false; | 80 return false; |
80 } | 81 } |
81 | 82 |
82 // Adds errors to |errors| if the certificate contains unconsumed _critical_ | 83 // Adds errors to |errors| if the certificate contains unconsumed _critical_ |
83 // extensions. | 84 // extensions. |
84 void VerifyNoUnconsumedCriticalExtensions(const ParsedCertificate& cert, | 85 void VerifyNoUnconsumedCriticalExtensions(const ParsedCertificate& cert, |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 // goes beyond what RFC 5280 describes, but is the de-facto standard. See | 601 // goes beyond what RFC 5280 describes, but is the de-facto standard. See |
601 // https://wiki.mozilla.org/CA:CertificatePolicyV2.1#Frequently_Asked_Questi
ons | 602 // https://wiki.mozilla.org/CA:CertificatePolicyV2.1#Frequently_Asked_Questi
ons |
602 VerifyExtendedKeyUsage(cert, required_key_purpose, cert_errors); | 603 VerifyExtendedKeyUsage(cert, required_key_purpose, cert_errors); |
603 | 604 |
604 if (!is_target_cert) { | 605 if (!is_target_cert) { |
605 PrepareForNextCertificate(cert, &max_path_length, &working_spki, | 606 PrepareForNextCertificate(cert, &max_path_length, &working_spki, |
606 &working_normalized_issuer_name, | 607 &working_normalized_issuer_name, |
607 &name_constraints_list, cert_errors); | 608 &name_constraints_list, cert_errors); |
608 } else { | 609 } else { |
609 WrapUp(cert, cert_errors); | 610 WrapUp(cert, cert_errors); |
610 // TODO(eroman): Verify the Key Usage on target is consistent with | |
611 // key_purpose. | |
612 } | 611 } |
613 } | 612 } |
614 | 613 |
615 // TODO(eroman): RFC 5280 forbids duplicate certificates per section 6.1: | 614 // TODO(eroman): RFC 5280 forbids duplicate certificates per section 6.1: |
616 // | 615 // |
617 // A certificate MUST NOT appear more than once in a prospective | 616 // A certificate MUST NOT appear more than once in a prospective |
618 // certification path. | 617 // certification path. |
619 } | 618 } |
620 | 619 |
621 } // namespace | 620 } // namespace |
622 | 621 |
623 bool VerifyCertificateChain(const ParsedCertificateList& certs, | 622 bool VerifyCertificateChain(const ParsedCertificateList& certs, |
624 const TrustAnchor* trust_anchor, | 623 const TrustAnchor* trust_anchor, |
625 const SignaturePolicy* signature_policy, | 624 const SignaturePolicy* signature_policy, |
626 const der::GeneralizedTime& time, | 625 const der::GeneralizedTime& time, |
627 KeyPurpose required_key_purpose, | 626 KeyPurpose required_key_purpose, |
628 CertPathErrors* errors) { | 627 CertPathErrors* errors) { |
629 // TODO(eroman): This function requires that |errors| is empty upon entry, | 628 // TODO(eroman): This function requires that |errors| is empty upon entry, |
630 // which is not part of the API contract. | 629 // which is not part of the API contract. |
631 DCHECK(!errors->ContainsHighSeverityErrors()); | 630 DCHECK(!errors->ContainsHighSeverityErrors()); |
632 VerifyCertificateChainNoReturnValue(certs, trust_anchor, signature_policy, | 631 VerifyCertificateChainNoReturnValue(certs, trust_anchor, signature_policy, |
633 time, required_key_purpose, errors); | 632 time, required_key_purpose, errors); |
634 return !errors->ContainsHighSeverityErrors(); | 633 return !errors->ContainsHighSeverityErrors(); |
635 } | 634 } |
636 | 635 |
637 } // namespace net | 636 } // namespace net |
OLD | NEW |