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

Side by Side Diff: chrome/browser/chromeos/policy/policy_cert_verifier.cc

Issue 2070223002: Remove CertTrustAnchorProvider from net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/chromeos/policy/policy_cert_verifier.h" 5 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 51 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
52 } 52 }
53 53
54 void PolicyCertVerifier::InitializeOnIOThread( 54 void PolicyCertVerifier::InitializeOnIOThread(
55 const scoped_refptr<net::CertVerifyProc>& verify_proc) { 55 const scoped_refptr<net::CertVerifyProc>& verify_proc) {
56 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 56 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
57 if (!verify_proc->SupportsAdditionalTrustAnchors()) { 57 if (!verify_proc->SupportsAdditionalTrustAnchors()) {
58 LOG(WARNING) 58 LOG(WARNING)
59 << "Additional trust anchors not supported on the current platform!"; 59 << "Additional trust anchors not supported on the current platform!";
60 } 60 }
61 std::unique_ptr<net::CachingCertVerifier> verifier = 61 delegate_ = base::MakeUnique<net::CachingCertVerifier>(
62 base::MakeUnique<net::CachingCertVerifier>( 62 base::MakeUnique<net::MultiThreadedCertVerifier>(verify_proc.get()));
63 base::MakeUnique<net::MultiThreadedCertVerifier>(verify_proc.get()));
64 verifier->SetCertTrustAnchorProvider(this);
65 delegate_ = std::move(verifier);
66 } 63 }
67 64
68 void PolicyCertVerifier::SetTrustAnchors( 65 void PolicyCertVerifier::SetTrustAnchors(
69 const net::CertificateList& trust_anchors) { 66 const net::CertificateList& trust_anchors) {
70 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 67 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
71 trust_anchors_ = trust_anchors; 68 trust_anchors_ = trust_anchors;
72 } 69 }
73 70
74 int PolicyCertVerifier::Verify( 71 int PolicyCertVerifier::Verify(
75 const RequestParams& params, 72 const RequestParams& params,
76 net::CRLSet* crl_set, 73 net::CRLSet* crl_set,
77 net::CertVerifyResult* verify_result, 74 net::CertVerifyResult* verify_result,
78 const net::CompletionCallback& completion_callback, 75 const net::CompletionCallback& completion_callback,
79 std::unique_ptr<Request>* out_req, 76 std::unique_ptr<Request>* out_req,
80 const net::BoundNetLog& net_log) { 77 const net::BoundNetLog& net_log) {
81 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 78 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
82 DCHECK(delegate_); 79 DCHECK(delegate_);
83 net::CompletionCallback wrapped_callback = 80 net::CompletionCallback wrapped_callback =
84 base::Bind(&CompleteAndSignalAnchorUse, 81 base::Bind(&CompleteAndSignalAnchorUse,
85 anchor_used_callback_, 82 anchor_used_callback_,
86 completion_callback, 83 completion_callback,
87 verify_result); 84 verify_result);
88 int error = delegate_->Verify(params, crl_set, verify_result, 85
86 CertificateList merged_trust_anchors(params.additional_trust_anchors());
eroman 2016/06/16 19:56:38 How about reserving the concatenated length first?
Ryan Sleevi 2016/06/16 21:07:14 .insert() does this prior to the insertion (since
eroman 2016/06/16 21:47:29 Not quite. This does two allocations: first it cop
Ryan Sleevi 2016/06/16 21:50:35 That's what I said.
87 merged_trust_anchors.insert(merged_trust_anchors.begin(),
88 trust_anchors_.begin(), trust_anchors_.end());
89 net::CertVerifier::RequestParams new_params(
90 params.certificate(), params.hostname(), params.flags(),
91 params.ocsp_response(), merged_trust_anchors);
92 int error = delegate_->Verify(new_params, crl_set, verify_result,
89 wrapped_callback, out_req, net_log); 93 wrapped_callback, out_req, net_log);
90 MaybeSignalAnchorUse(error, anchor_used_callback_, *verify_result); 94 MaybeSignalAnchorUse(error, anchor_used_callback_, *verify_result);
91 return error; 95 return error;
92 } 96 }
93 97
94 bool PolicyCertVerifier::SupportsOCSPStapling() { 98 bool PolicyCertVerifier::SupportsOCSPStapling() {
95 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 99 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
96 return delegate_->SupportsOCSPStapling(); 100 return delegate_->SupportsOCSPStapling();
97 } 101 }
98 102
99 const net::CertificateList& PolicyCertVerifier::GetAdditionalTrustAnchors() {
100 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
101 return trust_anchors_;
102 }
103
104 } // namespace policy 103 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698