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_win.h" | 5 #include "net/cert/cert_verify_proc_win.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
552 } // namespace | 552 } // namespace |
553 | 553 |
554 CertVerifyProcWin::CertVerifyProcWin() {} | 554 CertVerifyProcWin::CertVerifyProcWin() {} |
555 | 555 |
556 CertVerifyProcWin::~CertVerifyProcWin() {} | 556 CertVerifyProcWin::~CertVerifyProcWin() {} |
557 | 557 |
558 bool CertVerifyProcWin::SupportsAdditionalTrustAnchors() const { | 558 bool CertVerifyProcWin::SupportsAdditionalTrustAnchors() const { |
559 return false; | 559 return false; |
560 } | 560 } |
561 | 561 |
562 bool CertVerifyProcWin::SupportsOCSPStapling() const { | |
563 // CERT_OCSP_RESPONSE_PROP_ID is only implemented on Vista+, but it can be | |
564 // set on Windows XP without error. There is some overhead from the server | |
565 // sending the OCSP response if it supports the extension, for the subset of | |
566 // XP clients who will request it but be unable to use it, but this is an | |
567 // acceptable trade-off for simplicity of implementation. | |
568 return true; | |
569 } | |
570 | |
562 int CertVerifyProcWin::VerifyInternal( | 571 int CertVerifyProcWin::VerifyInternal( |
563 X509Certificate* cert, | 572 X509Certificate* cert, |
564 const std::string& hostname, | 573 const std::string& hostname, |
574 const std::string& ocsp_response, | |
565 int flags, | 575 int flags, |
566 CRLSet* crl_set, | 576 CRLSet* crl_set, |
567 const CertificateList& additional_trust_anchors, | 577 const CertificateList& additional_trust_anchors, |
568 CertVerifyResult* verify_result) { | 578 CertVerifyResult* verify_result) { |
569 PCCERT_CONTEXT cert_handle = cert->os_cert_handle(); | 579 PCCERT_CONTEXT cert_handle = cert->os_cert_handle(); |
570 if (!cert_handle) | 580 if (!cert_handle) |
571 return ERR_UNEXPECTED; | 581 return ERR_UNEXPECTED; |
572 | 582 |
573 // Build and validate certificate chain. | 583 // Build and validate certificate chain. |
574 CERT_CHAIN_PARA chain_para; | 584 CERT_CHAIN_PARA chain_para; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
626 // crypt32. However, when testing, it is necessary to create a new | 636 // crypt32. However, when testing, it is necessary to create a new |
627 // HCERTCHAINENGINE and use that instead. This is because each | 637 // HCERTCHAINENGINE and use that instead. This is because each |
628 // HCERTCHAINENGINE maintains a cache of information about certificates | 638 // HCERTCHAINENGINE maintains a cache of information about certificates |
629 // encountered, and each test run may modify the trust status of a | 639 // encountered, and each test run may modify the trust status of a |
630 // certificate. | 640 // certificate. |
631 ScopedHCERTCHAINENGINE chain_engine(NULL); | 641 ScopedHCERTCHAINENGINE chain_engine(NULL); |
632 if (TestRootCerts::HasInstance()) | 642 if (TestRootCerts::HasInstance()) |
633 chain_engine.reset(TestRootCerts::GetInstance()->GetChainEngine()); | 643 chain_engine.reset(TestRootCerts::GetInstance()->GetChainEngine()); |
634 | 644 |
635 ScopedPCCERT_CONTEXT cert_list(cert->CreateOSCertChainForCert()); | 645 ScopedPCCERT_CONTEXT cert_list(cert->CreateOSCertChainForCert()); |
646 | |
647 if (!ocsp_response.empty()) { | |
648 // Attach the OCSP response to the chain. | |
649 CRYPT_DATA_BLOB ocsp_response_blob; | |
650 ocsp_response_blob.cbData = ocsp_response.size(); | |
651 ocsp_response_blob.pbData = | |
652 reinterpret_cast<BYTE*>(const_cast<char*>(ocsp_response.data())); | |
653 BOOL ok = CertSetCertificateContextProperty( | |
654 cert_list.get(), CERT_OCSP_RESPONSE_PROP_ID, | |
655 CERT_SET_PROPERTY_IGNORE_PERSIST_ERROR_FLAG, &ocsp_response_blob); | |
656 if (!ok) { | |
657 VLOG(1) << "Failed to set OCSP response property: " << GetLastError(); | |
Ryan Sleevi
2015/04/23 01:41:23
Time to nuke this; we've never once used it, and w
davidben
2015/04/23 20:41:47
Done.
| |
658 } | |
659 } | |
660 | |
636 PCCERT_CHAIN_CONTEXT chain_context; | 661 PCCERT_CHAIN_CONTEXT chain_context; |
637 // IE passes a non-NULL pTime argument that specifies the current system | 662 // IE passes a non-NULL pTime argument that specifies the current system |
638 // time. IE passes CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT as the | 663 // time. IE passes CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT as the |
639 // chain_flags argument. | 664 // chain_flags argument. |
640 if (!CertGetCertificateChain( | 665 if (!CertGetCertificateChain( |
641 chain_engine, | 666 chain_engine, |
642 cert_list.get(), | 667 cert_list.get(), |
643 NULL, // current system time | 668 NULL, // current system time |
644 cert_list->hCertStore, | 669 cert_list->hCertStore, |
645 &chain_para, | 670 &chain_para, |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
803 return MapCertStatusToNetError(verify_result->cert_status); | 828 return MapCertStatusToNetError(verify_result->cert_status); |
804 | 829 |
805 if (ev_policy_oid && | 830 if (ev_policy_oid && |
806 CheckEV(chain_context, rev_checking_enabled, ev_policy_oid)) { | 831 CheckEV(chain_context, rev_checking_enabled, ev_policy_oid)) { |
807 verify_result->cert_status |= CERT_STATUS_IS_EV; | 832 verify_result->cert_status |= CERT_STATUS_IS_EV; |
808 } | 833 } |
809 return OK; | 834 return OK; |
810 } | 835 } |
811 | 836 |
812 } // namespace net | 837 } // namespace net |
OLD | NEW |