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/base/cert_verify_proc_win.h" | 5 #include "net/base/cert_verify_proc_win.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/sha1.h" | 8 #include "base/sha1.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 // two usages. | 534 // two usages. |
535 static const LPSTR usage[] = { | 535 static const LPSTR usage[] = { |
536 szOID_PKIX_KP_SERVER_AUTH, | 536 szOID_PKIX_KP_SERVER_AUTH, |
537 szOID_SERVER_GATED_CRYPTO, | 537 szOID_SERVER_GATED_CRYPTO, |
538 szOID_SGC_NETSCAPE | 538 szOID_SGC_NETSCAPE |
539 }; | 539 }; |
540 chain_para.RequestedUsage.dwType = USAGE_MATCH_TYPE_OR; | 540 chain_para.RequestedUsage.dwType = USAGE_MATCH_TYPE_OR; |
541 chain_para.RequestedUsage.Usage.cUsageIdentifier = arraysize(usage); | 541 chain_para.RequestedUsage.Usage.cUsageIdentifier = arraysize(usage); |
542 chain_para.RequestedUsage.Usage.rgpszUsageIdentifier = | 542 chain_para.RequestedUsage.Usage.rgpszUsageIdentifier = |
543 const_cast<LPSTR*>(usage); | 543 const_cast<LPSTR*>(usage); |
544 // We can set CERT_CHAIN_RETURN_LOWER_QUALITY_CONTEXTS to get more chains. | |
545 DWORD chain_flags = CERT_CHAIN_CACHE_END_CERT | | |
546 CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT; | |
547 const bool rev_checking_enabled = | |
548 flags & X509Certificate::VERIFY_REV_CHECKING_ENABLED; | |
549 | |
550 if (rev_checking_enabled) { | |
551 verify_result->cert_status |= CERT_STATUS_REV_CHECKING_ENABLED; | |
552 } else { | |
553 chain_flags |= CERT_CHAIN_REVOCATION_CHECK_CACHE_ONLY; | |
554 } | |
555 | 544 |
556 // Get the certificatePolicies extension of the certificate. | 545 // Get the certificatePolicies extension of the certificate. |
557 scoped_ptr_malloc<CERT_POLICIES_INFO> policies_info; | 546 scoped_ptr_malloc<CERT_POLICIES_INFO> policies_info; |
558 LPSTR ev_policy_oid = NULL; | 547 LPSTR ev_policy_oid = NULL; |
559 if (flags & X509Certificate::VERIFY_EV_CERT) { | 548 if (flags & X509Certificate::VERIFY_EV_CERT) { |
560 GetCertPoliciesInfo(cert_handle, &policies_info); | 549 GetCertPoliciesInfo(cert_handle, &policies_info); |
561 if (policies_info.get()) { | 550 if (policies_info.get()) { |
562 EVRootCAMetadata* metadata = EVRootCAMetadata::GetInstance(); | 551 EVRootCAMetadata* metadata = EVRootCAMetadata::GetInstance(); |
563 for (DWORD i = 0; i < policies_info->cPolicyInfo; ++i) { | 552 for (DWORD i = 0; i < policies_info->cPolicyInfo; ++i) { |
564 LPSTR policy_oid = policies_info->rgPolicyInfo[i].pszPolicyIdentifier; | 553 LPSTR policy_oid = policies_info->rgPolicyInfo[i].pszPolicyIdentifier; |
565 if (metadata->IsEVPolicyOID(policy_oid)) { | 554 if (metadata->IsEVPolicyOID(policy_oid)) { |
566 ev_policy_oid = policy_oid; | 555 ev_policy_oid = policy_oid; |
567 chain_para.RequestedIssuancePolicy.dwType = USAGE_MATCH_TYPE_AND; | 556 chain_para.RequestedIssuancePolicy.dwType = USAGE_MATCH_TYPE_AND; |
568 chain_para.RequestedIssuancePolicy.Usage.cUsageIdentifier = 1; | 557 chain_para.RequestedIssuancePolicy.Usage.cUsageIdentifier = 1; |
569 chain_para.RequestedIssuancePolicy.Usage.rgpszUsageIdentifier = | 558 chain_para.RequestedIssuancePolicy.Usage.rgpszUsageIdentifier = |
570 &ev_policy_oid; | 559 &ev_policy_oid; |
571 break; | 560 break; |
572 } | 561 } |
573 } | 562 } |
574 } | 563 } |
575 } | 564 } |
576 | 565 |
| 566 // We can set CERT_CHAIN_RETURN_LOWER_QUALITY_CONTEXTS to get more chains. |
| 567 DWORD chain_flags = CERT_CHAIN_CACHE_END_CERT | |
| 568 CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT; |
| 569 const bool rev_checking_enabled = |
| 570 (flags & X509Certificate::VERIFY_REV_CHECKING_ENABLED) || |
| 571 (ev_policy_oid != NULL && |
| 572 (flags & X509Certificate::VERIFY_REV_CHECKING_ENABLED_EV_ONLY)); |
| 573 |
| 574 if (rev_checking_enabled) { |
| 575 verify_result->cert_status |= CERT_STATUS_REV_CHECKING_ENABLED; |
| 576 } else { |
| 577 chain_flags |= CERT_CHAIN_REVOCATION_CHECK_CACHE_ONLY; |
| 578 } |
| 579 |
577 // For non-test scenarios, use the default HCERTCHAINENGINE, NULL, which | 580 // For non-test scenarios, use the default HCERTCHAINENGINE, NULL, which |
578 // corresponds to HCCE_CURRENT_USER and is is initialized as needed by | 581 // corresponds to HCCE_CURRENT_USER and is is initialized as needed by |
579 // crypt32. However, when testing, it is necessary to create a new | 582 // crypt32. However, when testing, it is necessary to create a new |
580 // HCERTCHAINENGINE and use that instead. This is because each | 583 // HCERTCHAINENGINE and use that instead. This is because each |
581 // HCERTCHAINENGINE maintains a cache of information about certificates | 584 // HCERTCHAINENGINE maintains a cache of information about certificates |
582 // encountered, and each test run may modify the trust status of a | 585 // encountered, and each test run may modify the trust status of a |
583 // certificate. | 586 // certificate. |
584 ScopedHCERTCHAINENGINE chain_engine(NULL); | 587 ScopedHCERTCHAINENGINE chain_engine(NULL); |
585 if (TestRootCerts::HasInstance()) | 588 if (TestRootCerts::HasInstance()) |
586 chain_engine.reset(TestRootCerts::GetInstance()->GetChainEngine()); | 589 chain_engine.reset(TestRootCerts::GetInstance()->GetChainEngine()); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 verify_result->is_issued_by_known_root = IsIssuedByKnownRoot(chain_context); | 736 verify_result->is_issued_by_known_root = IsIssuedByKnownRoot(chain_context); |
734 | 737 |
735 if (ev_policy_oid && | 738 if (ev_policy_oid && |
736 CheckEV(chain_context, rev_checking_enabled, ev_policy_oid)) { | 739 CheckEV(chain_context, rev_checking_enabled, ev_policy_oid)) { |
737 verify_result->cert_status |= CERT_STATUS_IS_EV; | 740 verify_result->cert_status |= CERT_STATUS_IS_EV; |
738 } | 741 } |
739 return OK; | 742 return OK; |
740 } | 743 } |
741 | 744 |
742 } // namespace net | 745 } // namespace net |
OLD | NEW |