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

Side by Side Diff: android_webview/native/aw_contents_client_bridge.cc

Issue 388683002: Switch OpenSSLClientKeyStore::ScopedEVP_PKEY to crypto::ScopedEVP_PKEY. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mis-split CL Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « android_webview/DEPS ('k') | chrome/browser/ui/android/ssl_client_certificate_request.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
15 #include "content/public/browser/render_view_host.h" 15 #include "content/public/browser/render_view_host.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "crypto/scoped_openssl_types.h"
17 #include "jni/AwContentsClientBridge_jni.h" 18 #include "jni/AwContentsClientBridge_jni.h"
18 #include "net/android/keystore_openssl.h" 19 #include "net/android/keystore_openssl.h"
19 #include "net/cert/x509_certificate.h" 20 #include "net/cert/x509_certificate.h"
20 #include "net/ssl/openssl_client_key_store.h" 21 #include "net/ssl/openssl_client_key_store.h"
21 #include "net/ssl/ssl_cert_request_info.h" 22 #include "net/ssl/ssl_cert_request_info.h"
22 #include "net/ssl/ssl_client_cert_type.h" 23 #include "net/ssl/ssl_client_cert_type.h"
23 #include "url/gurl.h" 24 #include "url/gurl.h"
24 25
25 using base::android::AttachCurrentThread; 26 using base::android::AttachCurrentThread;
26 using base::android::ConvertJavaStringToUTF16; 27 using base::android::ConvertJavaStringToUTF16;
27 using base::android::ConvertUTF8ToJavaString; 28 using base::android::ConvertUTF8ToJavaString;
28 using base::android::ConvertUTF16ToJavaString; 29 using base::android::ConvertUTF16ToJavaString;
29 using base::android::JavaRef; 30 using base::android::JavaRef;
30 using base::android::ScopedJavaLocalRef; 31 using base::android::ScopedJavaLocalRef;
31 using content::BrowserThread; 32 using content::BrowserThread;
32 33
33 namespace android_webview { 34 namespace android_webview {
34 35
35 typedef net::OpenSSLClientKeyStore::ScopedEVP_PKEY ScopedEVP_PKEY;
36
37 namespace { 36 namespace {
38 37
39 // Must be called on the I/O thread to record a client certificate 38 // Must be called on the I/O thread to record a client certificate
40 // and its private key in the OpenSSLClientKeyStore. 39 // and its private key in the OpenSSLClientKeyStore.
41 void RecordClientCertificateKey( 40 void RecordClientCertificateKey(
42 const scoped_refptr<net::X509Certificate>& client_cert, 41 const scoped_refptr<net::X509Certificate>& client_cert,
43 ScopedEVP_PKEY private_key) { 42 crypto::ScopedEVP_PKEY private_key) {
44 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 43 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
45 net::OpenSSLClientKeyStore::GetInstance()->RecordClientCertPrivateKey( 44 net::OpenSSLClientKeyStore::GetInstance()->RecordClientCertPrivateKey(
46 client_cert.get(), private_key.get()); 45 client_cert.get(), private_key.get());
47 } 46 }
48 47
49 } // namespace 48 } // namespace
50 49
51 AwContentsClientBridge::AwContentsClientBridge(JNIEnv* env, jobject obj) 50 AwContentsClientBridge::AwContentsClientBridge(JNIEnv* env, jobject obj)
52 : java_ref_(env, obj) { 51 : java_ref_(env, obj) {
53 DCHECK(obj); 52 DCHECK(obj);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 222
224 // Create the X509Certificate object from the encoded chain. 223 // Create the X509Certificate object from the encoded chain.
225 scoped_refptr<net::X509Certificate> client_cert( 224 scoped_refptr<net::X509Certificate> client_cert(
226 net::X509Certificate::CreateFromDERCertChain(encoded_chain)); 225 net::X509Certificate::CreateFromDERCertChain(encoded_chain));
227 if (!client_cert.get()) { 226 if (!client_cert.get()) {
228 LOG(ERROR) << "Could not decode client certificate chain"; 227 LOG(ERROR) << "Could not decode client certificate chain";
229 return; 228 return;
230 } 229 }
231 230
232 // Create an EVP_PKEY wrapper for the private key JNI reference. 231 // Create an EVP_PKEY wrapper for the private key JNI reference.
233 ScopedEVP_PKEY private_key( 232 crypto::ScopedEVP_PKEY private_key(
234 net::android::GetOpenSSLPrivateKeyWrapper(private_key_ref)); 233 net::android::GetOpenSSLPrivateKeyWrapper(private_key_ref));
235 if (!private_key.get()) { 234 if (!private_key.get()) {
236 LOG(ERROR) << "Could not create OpenSSL wrapper for private key"; 235 LOG(ERROR) << "Could not create OpenSSL wrapper for private key";
237 return; 236 return;
238 } 237 }
239 238
240 // RecordClientCertificateKey() must be called on the I/O thread, 239 // RecordClientCertificateKey() must be called on the I/O thread,
241 // before the callback is called with the selected certificate on 240 // before the callback is called with the selected certificate on
242 // the UI thread. 241 // the UI thread.
243 content::BrowserThread::PostTaskAndReply( 242 content::BrowserThread::PostTaskAndReply(
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 pending_client_cert_request_callbacks_.Lookup(request_id); 377 pending_client_cert_request_callbacks_.Lookup(request_id);
379 callback->Run(scoped_refptr<net::X509Certificate>()); 378 callback->Run(scoped_refptr<net::X509Certificate>());
380 pending_client_cert_request_callbacks_.Remove(request_id); 379 pending_client_cert_request_callbacks_.Remove(request_id);
381 } 380 }
382 381
383 bool RegisterAwContentsClientBridge(JNIEnv* env) { 382 bool RegisterAwContentsClientBridge(JNIEnv* env) {
384 return RegisterNativesImpl(env); 383 return RegisterNativesImpl(env);
385 } 384 }
386 385
387 } // namespace android_webview 386 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/DEPS ('k') | chrome/browser/ui/android/ssl_client_certificate_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698