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

Side by Side Diff: content/browser/ssl/ssl_client_auth_handler.cc

Issue 1304143010: Plumbing SSLPrivateKey Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing upload and refptr. Created 5 years, 2 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) 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 "content/browser/ssl/ssl_client_auth_handler.h" 5 #include "content/browser/ssl/ssl_client_auth_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/client_certificate_delegate.h" 10 #include "content/public/browser/client_certificate_delegate.h"
(...skipping 18 matching lines...) Expand all
29 ~ClientCertificateDelegateImpl() override { 29 ~ClientCertificateDelegateImpl() override {
30 if (!continue_called_) { 30 if (!continue_called_) {
31 BrowserThread::PostTask( 31 BrowserThread::PostTask(
32 BrowserThread::IO, FROM_HERE, 32 BrowserThread::IO, FROM_HERE,
33 base::Bind(&SSLClientAuthHandler::CancelCertificateSelection, 33 base::Bind(&SSLClientAuthHandler::CancelCertificateSelection,
34 handler_)); 34 handler_));
35 } 35 }
36 } 36 }
37 37
38 // ClientCertificateDelegate implementation: 38 // ClientCertificateDelegate implementation:
39 void ContinueWithCertificate(net::X509Certificate* cert) override { 39 void ContinueWithCertificate(net::X509Certificate* cert,
40 net::SSLPrivateKey* private_key) override {
40 DCHECK(!continue_called_); 41 DCHECK(!continue_called_);
41 continue_called_ = true; 42 continue_called_ = true;
42 BrowserThread::PostTask( 43 BrowserThread::PostTask(
43 BrowserThread::IO, FROM_HERE, 44 BrowserThread::IO, FROM_HERE,
44 base::Bind(&SSLClientAuthHandler::ContinueWithCertificate, handler_, 45 base::Bind(&SSLClientAuthHandler::ContinueWithCertificate, handler_,
45 make_scoped_refptr(cert))); 46 make_scoped_refptr(cert), make_scoped_refptr(private_key)));
46 } 47 }
47 48
48 private: 49 private:
49 base::WeakPtr<SSLClientAuthHandler> handler_; 50 base::WeakPtr<SSLClientAuthHandler> handler_;
50 bool continue_called_; 51 bool continue_called_;
51 52
52 DISALLOW_COPY_AND_ASSIGN(ClientCertificateDelegateImpl); 53 DISALLOW_COPY_AND_ASSIGN(ClientCertificateDelegateImpl);
53 }; 54 };
54 55
55 void SelectCertificateOnUIThread( 56 void SelectCertificateOnUIThread(
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 void SSLClientAuthHandler::SelectCertificate() { 139 void SSLClientAuthHandler::SelectCertificate() {
139 DCHECK_CURRENTLY_ON(BrowserThread::IO); 140 DCHECK_CURRENTLY_ON(BrowserThread::IO);
140 141
141 // |core_| will call DidGetClientCerts when done. 142 // |core_| will call DidGetClientCerts when done.
142 core_->GetClientCerts(); 143 core_->GetClientCerts();
143 } 144 }
144 145
145 // static 146 // static
146 void SSLClientAuthHandler::ContinueWithCertificate( 147 void SSLClientAuthHandler::ContinueWithCertificate(
147 const base::WeakPtr<SSLClientAuthHandler>& handler, 148 const base::WeakPtr<SSLClientAuthHandler>& handler,
148 net::X509Certificate* cert) { 149 net::X509Certificate* cert,
150 net::SSLPrivateKey* private_key) {
149 if (handler) 151 if (handler)
150 handler->delegate_->ContinueWithCertificate(cert); 152 handler->delegate_->ContinueWithCertificate(cert, private_key);
151 } 153 }
152 154
153 // static 155 // static
154 void SSLClientAuthHandler::CancelCertificateSelection( 156 void SSLClientAuthHandler::CancelCertificateSelection(
155 const base::WeakPtr<SSLClientAuthHandler>& handler) { 157 const base::WeakPtr<SSLClientAuthHandler>& handler) {
156 if (handler) 158 if (handler)
157 handler->delegate_->CancelCertificateSelection(); 159 handler->delegate_->CancelCertificateSelection();
158 } 160 }
159 161
160 void SSLClientAuthHandler::DidGetClientCerts() { 162 void SSLClientAuthHandler::DidGetClientCerts() {
161 DCHECK_CURRENTLY_ON(BrowserThread::IO); 163 DCHECK_CURRENTLY_ON(BrowserThread::IO);
162 164
163 // Note that if |client_cert_store_| is NULL, we intentionally fall through to 165 // Note that if |client_cert_store_| is NULL, we intentionally fall through to
164 // SelectCertificateOnUIThread. This is for platforms where the client cert 166 // SelectCertificateOnUIThread. This is for platforms where the client cert
165 // matching is not performed by Chrome. Those platforms handle the cert 167 // matching is not performed by Chrome. Those platforms handle the cert
166 // matching before showing the dialog. 168 // matching before showing the dialog.
167 if (core_->has_client_cert_store() && 169 if (core_->has_client_cert_store() &&
168 cert_request_info_->client_certs.empty()) { 170 cert_request_info_->client_certs.empty()) {
169 // No need to query the user if there are no certs to choose from. 171 // No need to query the user if there are no certs to choose from.
170 // 172 //
171 // TODO(davidben): The WebContents-less check on the UI thread should come 173 // TODO(davidben): The WebContents-less check on the UI thread should come
172 // before checking ClientCertStore; ClientCertStore itself should probably 174 // before checking ClientCertStore; ClientCertStore itself should probably
173 // be handled by the embedder (https://crbug.com/394131), especially since 175 // be handled by the embedder (https://crbug.com/394131), especially since
174 // this doesn't work on Android (https://crbug.com/345641). 176 // this doesn't work on Android (https://crbug.com/345641).
175 BrowserThread::PostTask( 177 BrowserThread::PostTask(
176 BrowserThread::IO, FROM_HERE, 178 BrowserThread::IO, FROM_HERE,
177 base::Bind(&SSLClientAuthHandler::ContinueWithCertificate, 179 base::Bind(&SSLClientAuthHandler::ContinueWithCertificate,
178 weak_factory_.GetWeakPtr(), 180 weak_factory_.GetWeakPtr(),
179 scoped_refptr<net::X509Certificate>())); 181 scoped_refptr<net::X509Certificate>(),
182 scoped_refptr<net::SSLPrivateKey>()));
180 return; 183 return;
181 } 184 }
182 185
183 int render_process_host_id; 186 int render_process_host_id;
184 int render_frame_host_id; 187 int render_frame_host_id;
185 if (!ResourceRequestInfo::ForRequest(request_)->GetAssociatedRenderFrame( 188 if (!ResourceRequestInfo::ForRequest(request_)->GetAssociatedRenderFrame(
186 &render_process_host_id, &render_frame_host_id)) { 189 &render_process_host_id, &render_frame_host_id)) {
187 NOTREACHED(); 190 NOTREACHED();
188 BrowserThread::PostTask( 191 BrowserThread::PostTask(
189 BrowserThread::IO, FROM_HERE, 192 BrowserThread::IO, FROM_HERE,
190 base::Bind(&SSLClientAuthHandler::CancelCertificateSelection, 193 base::Bind(&SSLClientAuthHandler::CancelCertificateSelection,
191 weak_factory_.GetWeakPtr())); 194 weak_factory_.GetWeakPtr()));
192 return; 195 return;
193 } 196 }
194 197
195 BrowserThread::PostTask( 198 BrowserThread::PostTask(
196 BrowserThread::UI, FROM_HERE, 199 BrowserThread::UI, FROM_HERE,
197 base::Bind(&SelectCertificateOnUIThread, render_process_host_id, 200 base::Bind(&SelectCertificateOnUIThread, render_process_host_id,
198 render_frame_host_id, cert_request_info_, 201 render_frame_host_id, cert_request_info_,
199 weak_factory_.GetWeakPtr())); 202 weak_factory_.GetWeakPtr()));
200 } 203 }
201 204
202 } // namespace content 205 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698