OLD | NEW |
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/ui/android/ssl_client_certificate_request.h" | 5 #include "chrome/browser/ui/android/ssl_client_certificate_request.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // Create the X509Certificate object from the encoded chain. | 154 // Create the X509Certificate object from the encoded chain. |
155 scoped_refptr<net::X509Certificate> client_cert( | 155 scoped_refptr<net::X509Certificate> client_cert( |
156 net::X509Certificate::CreateFromDERCertChain(encoded_chain)); | 156 net::X509Certificate::CreateFromDERCertChain(encoded_chain)); |
157 if (!client_cert.get()) { | 157 if (!client_cert.get()) { |
158 LOG(ERROR) << "Could not decode client certificate chain"; | 158 LOG(ERROR) << "Could not decode client certificate chain"; |
159 return; | 159 return; |
160 } | 160 } |
161 | 161 |
162 // Create an SSLPrivateKey wrapper for the private key JNI reference. | 162 // Create an SSLPrivateKey wrapper for the private key JNI reference. |
163 scoped_refptr<net::SSLPrivateKey> private_key = | 163 scoped_refptr<net::SSLPrivateKey> private_key = |
164 net::WrapJavaPrivateKey(private_key_ref); | 164 net::WrapJavaPrivateKey(client_cert.get(), private_key_ref); |
165 if (!private_key) { | 165 if (!private_key) { |
166 LOG(ERROR) << "Could not create OpenSSL wrapper for private key"; | 166 LOG(ERROR) << "Could not create OpenSSL wrapper for private key"; |
167 return; | 167 return; |
168 } | 168 } |
169 | 169 |
170 // RecordClientCertificateKey() must be called on the I/O thread, | 170 // RecordClientCertificateKey() must be called on the I/O thread, |
171 // before the callback is called with the selected certificate on | 171 // before the callback is called with the selected certificate on |
172 // the UI thread. | 172 // the UI thread. |
173 content::BrowserThread::PostTaskAndReply( | 173 content::BrowserThread::PostTaskAndReply( |
174 content::BrowserThread::IO, FROM_HERE, | 174 content::BrowserThread::IO, FROM_HERE, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 net::SSLCertRequestInfo* cert_request_info, | 207 net::SSLCertRequestInfo* cert_request_info, |
208 std::unique_ptr<content::ClientCertificateDelegate> delegate) { | 208 std::unique_ptr<content::ClientCertificateDelegate> delegate) { |
209 ui::WindowAndroid* window = ViewAndroidHelper::FromWebContents(contents) | 209 ui::WindowAndroid* window = ViewAndroidHelper::FromWebContents(contents) |
210 ->GetViewAndroid()->GetWindowAndroid(); | 210 ->GetViewAndroid()->GetWindowAndroid(); |
211 DCHECK(window); | 211 DCHECK(window); |
212 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 212 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
213 StartClientCertificateRequest(cert_request_info, window, std::move(delegate)); | 213 StartClientCertificateRequest(cert_request_info, window, std::move(delegate)); |
214 } | 214 } |
215 | 215 |
216 } // namespace chrome | 216 } // namespace chrome |
OLD | NEW |