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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 encoded_chain.push_back(encoded_chain_strings[n]); | 143 encoded_chain.push_back(encoded_chain_strings[n]); |
144 | 144 |
145 // Create the X509Certificate object from the encoded chain. | 145 // Create the X509Certificate object from the encoded chain. |
146 scoped_refptr<net::X509Certificate> client_cert( | 146 scoped_refptr<net::X509Certificate> client_cert( |
147 net::X509Certificate::CreateFromDERCertChain(encoded_chain)); | 147 net::X509Certificate::CreateFromDERCertChain(encoded_chain)); |
148 if (!client_cert.get()) { | 148 if (!client_cert.get()) { |
149 LOG(ERROR) << "Could not decode client certificate chain"; | 149 LOG(ERROR) << "Could not decode client certificate chain"; |
150 return; | 150 return; |
151 } | 151 } |
152 | 152 |
153 // Create an EVP_PKEY wrapper for the private key JNI reference. | |
154 crypto::ScopedEVP_PKEY private_key( | |
155 net::android::GetOpenSSLPrivateKeyWrapper(private_key_ref)); | |
156 if (!private_key.get()) { | |
157 LOG(ERROR) << "Could not create OpenSSL wrapper for private key"; | |
158 return; | |
159 } | |
160 | |
161 scoped_refptr<net::SSLPrivateKey> client_private_key = | 153 scoped_refptr<net::SSLPrivateKey> client_private_key = |
162 net::WrapOpenSSLPrivateKey(std::move(private_key)); | 154 net::WrapJavaPrivateKey(private_key_ref.obj()); |
163 | 155 |
164 content::BrowserThread::PostTask( | 156 content::BrowserThread::PostTask( |
165 content::BrowserThread::IO, FROM_HERE, | 157 content::BrowserThread::IO, FROM_HERE, |
166 base::Bind(&content::ClientCertificateDelegate::ContinueWithCertificate, | 158 base::Bind(&content::ClientCertificateDelegate::ContinueWithCertificate, |
167 base::Owned(delegate.release()), client_cert, | 159 base::Owned(delegate.release()), client_cert, |
168 client_private_key)); | 160 client_private_key)); |
169 } | 161 } |
170 | 162 |
171 static void NotifyClientCertificatesChanged() { | 163 static void NotifyClientCertificatesChanged() { |
172 net::CertDatabase::GetInstance()->OnAndroidKeyStoreChanged(); | 164 net::CertDatabase::GetInstance()->OnAndroidKeyStoreChanged(); |
(...skipping 23 matching lines...) Expand all Loading... |
196 net::SSLCertRequestInfo* cert_request_info, | 188 net::SSLCertRequestInfo* cert_request_info, |
197 scoped_ptr<content::ClientCertificateDelegate> delegate) { | 189 scoped_ptr<content::ClientCertificateDelegate> delegate) { |
198 ui::WindowAndroid* window = ViewAndroidHelper::FromWebContents(contents) | 190 ui::WindowAndroid* window = ViewAndroidHelper::FromWebContents(contents) |
199 ->GetViewAndroid()->GetWindowAndroid(); | 191 ->GetViewAndroid()->GetWindowAndroid(); |
200 DCHECK(window); | 192 DCHECK(window); |
201 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 193 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
202 StartClientCertificateRequest(cert_request_info, window, std::move(delegate)); | 194 StartClientCertificateRequest(cert_request_info, window, std::move(delegate)); |
203 } | 195 } |
204 | 196 |
205 } // namespace chrome | 197 } // namespace chrome |
OLD | NEW |