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 "android_webview/native/aw_contents_client_bridge.h" | 5 #include "android_webview/native/aw_contents_client_bridge.h" |
6 | 6 |
7 #include "android_webview/common/devtools_instrumentation.h" | 7 #include "android_webview/common/devtools_instrumentation.h" |
8 #include "android_webview/native/aw_contents.h" | 8 #include "android_webview/native/aw_contents.h" |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/client_certificate_delegate.h" | 15 #include "content/public/browser/client_certificate_delegate.h" |
16 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
17 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
19 #include "crypto/scoped_openssl_types.h" | 19 #include "crypto/scoped_openssl_types.h" |
20 #include "jni/AwContentsClientBridge_jni.h" | 20 #include "jni/AwContentsClientBridge_jni.h" |
21 #include "net/android/keystore_openssl.h" | 21 #include "net/android/keystore_openssl.h" |
22 #include "net/cert/x509_certificate.h" | 22 #include "net/cert/x509_certificate.h" |
23 #include "net/ssl/ssl_cert_request_info.h" | 23 #include "net/ssl/ssl_cert_request_info.h" |
24 #include "net/ssl/ssl_client_cert_type.h" | 24 #include "net/ssl/ssl_client_cert_type.h" |
25 #include "net/ssl/ssl_platform_key.h" | 25 #include "net/ssl/ssl_platform_key_android.h" |
26 #include "net/ssl/ssl_private_key.h" | 26 #include "net/ssl/ssl_private_key.h" |
27 #include "url/gurl.h" | 27 #include "url/gurl.h" |
28 | 28 |
29 using base::android::AttachCurrentThread; | 29 using base::android::AttachCurrentThread; |
30 using base::android::ConvertJavaStringToUTF16; | 30 using base::android::ConvertJavaStringToUTF16; |
31 using base::android::ConvertUTF8ToJavaString; | 31 using base::android::ConvertUTF8ToJavaString; |
32 using base::android::ConvertUTF16ToJavaString; | 32 using base::android::ConvertUTF16ToJavaString; |
33 using base::android::JavaRef; | 33 using base::android::JavaRef; |
34 using base::android::ScopedJavaLocalRef; | 34 using base::android::ScopedJavaLocalRef; |
35 using content::BrowserThread; | 35 using content::BrowserThread; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 encoded_chain.push_back(encoded_chain_strings[i]); | 220 encoded_chain.push_back(encoded_chain_strings[i]); |
221 | 221 |
222 // Create the X509Certificate object from the encoded chain. | 222 // Create the X509Certificate object from the encoded chain. |
223 scoped_refptr<net::X509Certificate> client_cert( | 223 scoped_refptr<net::X509Certificate> client_cert( |
224 net::X509Certificate::CreateFromDERCertChain(encoded_chain)); | 224 net::X509Certificate::CreateFromDERCertChain(encoded_chain)); |
225 if (!client_cert.get()) { | 225 if (!client_cert.get()) { |
226 LOG(ERROR) << "Could not decode client certificate chain"; | 226 LOG(ERROR) << "Could not decode client certificate chain"; |
227 return; | 227 return; |
228 } | 228 } |
229 | 229 |
230 // Create an EVP_PKEY wrapper for the private key JNI reference. | |
231 crypto::ScopedEVP_PKEY private_key( | |
232 net::android::GetOpenSSLPrivateKeyWrapper(private_key_ref.obj())); | |
233 if (!private_key.get()) { | |
234 LOG(ERROR) << "Could not create OpenSSL wrapper for private key"; | |
235 return; | |
236 } | |
237 | |
238 scoped_refptr<net::SSLPrivateKey> client_private_key = | 230 scoped_refptr<net::SSLPrivateKey> client_private_key = |
239 net::WrapOpenSSLPrivateKey(std::move(private_key)); | 231 net::WrapJavaPrivateKey(private_key_ref.obj()); |
240 | 232 |
241 // Release the guard and |pending_client_cert_request_delegates_| references | 233 // Release the guard and |pending_client_cert_request_delegates_| references |
242 // to |delegate|. | 234 // to |delegate|. |
243 pending_client_cert_request_delegates_.Remove(request_id); | 235 pending_client_cert_request_delegates_.Remove(request_id); |
244 ignore_result(guard.Release()); | 236 ignore_result(guard.Release()); |
245 | 237 |
246 // RecordClientCertificateKey() must be called on the I/O thread, | 238 // RecordClientCertificateKey() must be called on the I/O thread, |
247 // before the delegate is called with the selected certificate on | 239 // before the delegate is called with the selected certificate on |
248 // the UI thread. | 240 // the UI thread. |
249 content::BrowserThread::PostTask( | 241 content::BrowserThread::PostTask( |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 pending_client_cert_request_delegates_.Remove(request_id); | 377 pending_client_cert_request_delegates_.Remove(request_id); |
386 | 378 |
387 delete delegate; | 379 delete delegate; |
388 } | 380 } |
389 | 381 |
390 bool RegisterAwContentsClientBridge(JNIEnv* env) { | 382 bool RegisterAwContentsClientBridge(JNIEnv* env) { |
391 return RegisterNativesImpl(env); | 383 return RegisterNativesImpl(env); |
392 } | 384 } |
393 | 385 |
394 } // namespace android_webview | 386 } // namespace android_webview |
OLD | NEW |