Refactor client cert private key handling.

https://codereview.chromium.org/2898573002
This commit is contained in:
Aleksei Kuzmin 2017-08-21 00:35:04 +03:00 committed by Cheng Zhao
parent b69913975b
commit 5831a5ffa1
6 changed files with 22 additions and 11 deletions

View file

@ -699,10 +699,17 @@ void App::AllowCertificateError(
void App::SelectClientCertificate(
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
net::CertificateList client_certs,
net::ClientCertIdentityList identities,
std::unique_ptr<content::ClientCertificateDelegate> delegate) {
std::shared_ptr<content::ClientCertificateDelegate>
shared_delegate(delegate.release());
// Convert the ClientCertIdentityList to a CertificateList
// to avoid changes in the API.
auto client_certs = net::CertificateList();
for (const std::unique_ptr<net::ClientCertIdentity>& identity : identities)
client_certs.push_back(identity->certificate());
bool prevent_default =
Emit("select-client-certificate",
WebContents::CreateFrom(isolate(), web_contents),

View file

@ -25,6 +25,7 @@
#include "native_mate/dictionary.h"
#include "native_mate/handle.h"
#include "net/base/completion_callback.h"
#include "net/ssl/client_cert_identity.h"
#if defined(USE_NSS_CERTS)
#include "chrome/browser/certificate_manager_model.h"
@ -149,7 +150,7 @@ class App : public AtomBrowserClient::Delegate,
void SelectClientCertificate(
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
net::CertificateList client_certs,
net::ClientCertIdentityList client_certs,
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
// content::GpuDataManagerObserver:

View file

@ -316,7 +316,7 @@ void AtomBrowserClient::AllowCertificateError(
void AtomBrowserClient::SelectClientCertificate(
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
net::CertificateList client_certs,
net::ClientCertIdentityList client_certs,
std::unique_ptr<content::ClientCertificateDelegate> delegate) {
if (!client_certs.empty() && delegate_) {
delegate_->SelectClientCertificate(web_contents, cert_request_info,

View file

@ -12,6 +12,7 @@
#include "brightray/browser/browser_client.h"
#include "content/public/browser/render_process_host_observer.h"
#include "net/ssl/client_cert_identity.h"
namespace content {
class QuotaPermissionContext;
@ -77,7 +78,7 @@ class AtomBrowserClient : public brightray::BrowserClient,
void SelectClientCertificate(
content::WebContents* web_contents,
net::SSLCertRequestInfo* cert_request_info,
net::CertificateList client_certs,
net::ClientCertIdentityList client_certs,
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
void ResourceDispatcherHostCreated() override;
bool CanCreateWindow(

View file

@ -5,6 +5,7 @@
#include "brightray/browser/net/devtools_network_transaction.h"
#include <string>
#include <utility>
#include "brightray/browser/net/devtools_network_controller.h"
#include "brightray/browser/net/devtools_network_upload_data_stream.h"
@ -165,18 +166,18 @@ int DevToolsNetworkTransaction::RestartIgnoringLastError(
}
int DevToolsNetworkTransaction::RestartWithCertificate(
net::X509Certificate* client_cert,
net::SSLPrivateKey* client_private_key,
scoped_refptr<net::X509Certificate> client_cert,
scoped_refptr<net::SSLPrivateKey> client_private_key,
const net::CompletionCallback& callback) {
if (CheckFailed())
return net::ERR_INTERNET_DISCONNECTED;
if (!interceptor_) {
return transaction_->RestartWithCertificate(
client_cert, client_private_key, callback);
std::move(client_cert), std::move(client_private_key), callback);
}
int result = transaction_->RestartWithCertificate(
client_cert, client_private_key,
std::move(client_cert), std::move(client_private_key),
base::Bind(&DevToolsNetworkTransaction::IOCallback,
base::Unretained(this), callback, true));
return Throttle(callback, true, result);

View file

@ -34,9 +34,10 @@ class DevToolsNetworkTransaction : public net::HttpTransaction {
const net::NetLogWithSource& net_log) override;
int RestartIgnoringLastError(
const net::CompletionCallback& callback) override;
int RestartWithCertificate(net::X509Certificate* client_cert,
net::SSLPrivateKey* client_private_key,
const net::CompletionCallback& callback) override;
int RestartWithCertificate(
scoped_refptr<net::X509Certificate> client_cert,
scoped_refptr<net::SSLPrivateKey> client_private_key,
const net::CompletionCallback& callback) override;
int RestartWithAuth(const net::AuthCredentials& credentials,
const net::CompletionCallback& callback) override;
bool IsReadyToRestartForAuth() override;