Commit 38c82b03 authored by Matt Mueller's avatar Matt Mueller Committed by Commit Bot

Remove URLRequestBuilder::set_shared_cert_verifier.

When using ProfileIOData::SetCertVerifierForTesting, the test verifier is wrapped in a per-profile object that queries the shared verifier. The lifetime requirements are unchanged (the test cert verifier must outlive any profiles using it).

Bug: 780611
Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I9be3d8e7591cf55a03d08382a82ef2f8124152a2
Reviewed-on: https://chromium-review.googlesource.com/756016
Commit-Queue: Matt Mueller <mattm@chromium.org>
Reviewed-by: default avatarRyan Sleevi <rsleevi@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#515065}
parent 57d408b8
......@@ -181,6 +181,34 @@ namespace {
net::CertVerifier* g_cert_verifier_for_testing = nullptr;
// A CertVerifier that forwards all requests to |g_cert_verifier_for_testing|.
// This is used to allow Profiles to have their own
// std::unique_ptr<net::CertVerifier> while forwarding calls to the shared
// verifier.
class WrappedTestingCertVerifier : public net::CertVerifier {
public:
~WrappedTestingCertVerifier() override = default;
// CertVerifier implementation
int Verify(const RequestParams& params,
net::CRLSet* crl_set,
net::CertVerifyResult* verify_result,
const net::CompletionCallback& callback,
std::unique_ptr<Request>* out_req,
const net::NetLogWithSource& net_log) override {
verify_result->Reset();
if (!g_cert_verifier_for_testing)
return net::ERR_FAILED;
return g_cert_verifier_for_testing->Verify(params, crl_set, verify_result,
callback, out_req, net_log);
}
bool SupportsOCSPStapling() override {
if (!g_cert_verifier_for_testing)
return false;
return g_cert_verifier_for_testing->SupportsOCSPStapling();
}
};
#if BUILDFLAG(DEBUG_DEVTOOLS)
bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) {
std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath);
......@@ -1100,7 +1128,7 @@ void ProfileIOData::Init(
#endif
if (g_cert_verifier_for_testing) {
builder->set_shared_cert_verifier(g_cert_verifier_for_testing);
builder->SetCertVerifier(std::make_unique<WrappedTestingCertVerifier>());
} else {
std::unique_ptr<net::CertVerifier> cert_verifier;
#if defined(OS_CHROMEOS)
......
......@@ -205,8 +205,7 @@ URLRequestContextBuilder::URLRequestContextBuilder()
pac_quick_check_enabled_(true),
pac_sanitize_url_policy_(ProxyService::SanitizeUrlPolicy::SAFE),
shared_proxy_delegate_(nullptr),
shared_http_auth_handler_factory_(nullptr),
shared_cert_verifier_(nullptr) {
shared_http_auth_handler_factory_(nullptr) {
}
URLRequestContextBuilder::~URLRequestContextBuilder() {}
......@@ -282,16 +281,9 @@ void URLRequestContextBuilder::set_ct_policy_enforcer(
void URLRequestContextBuilder::SetCertVerifier(
std::unique_ptr<CertVerifier> cert_verifier) {
DCHECK(!shared_cert_verifier_);
cert_verifier_ = std::move(cert_verifier);
}
void URLRequestContextBuilder::set_shared_cert_verifier(
CertVerifier* shared_cert_verifier) {
DCHECK(!cert_verifier_);
shared_cert_verifier_ = shared_cert_verifier;
}
#if BUILDFLAG(ENABLE_REPORTING)
void URLRequestContextBuilder::set_reporting_policy(
std::unique_ptr<net::ReportingPolicy> reporting_policy) {
......@@ -476,10 +468,7 @@ std::unique_ptr<URLRequestContext> URLRequestContextBuilder::Build() {
}
if (cert_verifier_) {
DCHECK(!shared_cert_verifier_);
storage->set_cert_verifier(std::move(cert_verifier_));
} else if (shared_cert_verifier_) {
context->set_cert_verifier(shared_cert_verifier_);
} else {
storage->set_cert_verifier(CertVerifier::CreateDefault());
}
......
......@@ -291,14 +291,6 @@ class NET_EXPORT URLRequestContextBuilder {
void SetCertVerifier(std::unique_ptr<CertVerifier> cert_verifier);
// Makes the created URLRequestContext use a shared CertVerifier object.
// Should not be used it SetCertVerifier() is used. The consumer must ensure
// the CertVerifier outlives the URLRequestContext returned by the builder.
//
// TODO(mmenke): Figure out if consumers can use SetCertVerifier instead. See:
// https://crbug.com/743251.
void set_shared_cert_verifier(CertVerifier* shared_cert_verifier);
#if BUILDFLAG(ENABLE_REPORTING)
void set_reporting_policy(
std::unique_ptr<net::ReportingPolicy> reporting_policy);
......@@ -399,7 +391,6 @@ class NET_EXPORT URLRequestContextBuilder {
std::unique_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_;
HttpAuthHandlerFactory* shared_http_auth_handler_factory_;
std::unique_ptr<CertVerifier> cert_verifier_;
CertVerifier* shared_cert_verifier_;
std::unique_ptr<CTVerifier> ct_verifier_;
std::unique_ptr<CTPolicyEnforcer> ct_policy_enforcer_;
#if BUILDFLAG(ENABLE_REPORTING)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment