| Index: content/browser/ssl/ssl_host_state.cc
|
| diff --git a/content/browser/ssl/ssl_host_state.cc b/content/browser/ssl/ssl_host_state.cc
|
| index 06c600205fa8b1277b5252e91cbbf56580320c21..a6d6a2cb0da1c12281d0f743b7cbde0d220b2fe9 100644
|
| --- a/content/browser/ssl/ssl_host_state.cc
|
| +++ b/content/browser/ssl/ssl_host_state.cc
|
| @@ -6,7 +6,13 @@
|
|
|
| #include "base/logging.h"
|
| #include "base/lazy_instance.h"
|
| +#include "base/pickle.h"
|
| #include "content/public/browser/browser_context.h"
|
| +#include "content/public/browser/ssl_host_state_decisions.h"
|
| +#include "net/http/http_transaction_factory.h"
|
| +#include "net/url_request/url_request_context.h"
|
| +#include "net/url_request/url_request_context_getter.h"
|
| +#include "url/gurl.h"
|
|
|
| const char kKeyName[] = "content_ssl_host_state";
|
|
|
| @@ -16,7 +22,10 @@ SSLHostState* SSLHostState::GetFor(BrowserContext* context) {
|
| SSLHostState* rv = static_cast<SSLHostState*>(context->GetUserData(kKeyName));
|
| if (!rv) {
|
| rv = new SSLHostState();
|
| - context->SetUserData(kKeyName, rv);
|
| + rv->decisions_ = context->GetSSLHostStateDecisions();
|
| + // |context| may be NULL, implementing the default storage strategy.
|
| + if (context)
|
| + context->SetUserData(kKeyName, rv);
|
| }
|
| return rv;
|
| }
|
| @@ -39,33 +48,73 @@ bool SSLHostState::DidHostRunInsecureContent(const std::string& host,
|
| }
|
|
|
| void SSLHostState::DenyCertForHost(net::X509Certificate* cert,
|
| - const std::string& host,
|
| + const GURL& url,
|
| net::CertStatus error) {
|
| DCHECK(CalledOnValidThread());
|
|
|
| - cert_policy_for_host_[host].Deny(cert, error);
|
| + if (!decisions_)
|
| + return;
|
| +
|
| + decisions_->DenyCert(url, cert, error);
|
| }
|
|
|
| void SSLHostState::AllowCertForHost(net::X509Certificate* cert,
|
| - const std::string& host,
|
| + const GURL& url,
|
| net::CertStatus error) {
|
| DCHECK(CalledOnValidThread());
|
|
|
| - cert_policy_for_host_[host].Allow(cert, error);
|
| + if (!decisions_)
|
| + return;
|
| +
|
| + decisions_->AllowCert(url, cert, error);
|
| }
|
|
|
| -void SSLHostState::Clear() {
|
| +void SSLHostState::RevokeAllowAndDenyPreferences(const GURL& url) {
|
| DCHECK(CalledOnValidThread());
|
|
|
| - cert_policy_for_host_.clear();
|
| + if (!decisions_)
|
| + return;
|
| +
|
| + // TODO(jww): This will revoke all of the decisions in the browser context.
|
| + // However, the networking stack actually keeps track of its own list of
|
| + // exceptions per-HttpNetworkTransaction in the SSLConfig structure (see the
|
| + // allowed_bad_certs Vector in net/ssl/ssl_config.h). This dual-tracking of
|
| + // exceptions introduces a problem where the browser context can revoke a
|
| + // certificate, but if a transaction reuses a cached version of the SSLConfig
|
| + // (probably from a pooled socket), it may bypass the intestitial layer.
|
| + //
|
| + // Over time, the cached versions should expire and it should converge on
|
| + // showing the interstitial. We probably need to
|
| + // introduce into the networking stack a way revoke SSLConfig's
|
| + // allowed_bad_certs lists per socket.
|
| + decisions_->RevokeAllowAndDenyPreferences(url);
|
| +}
|
| +
|
| +bool SSLHostState::HasAllowedOrDeniedCert(const GURL& url) {
|
| + DCHECK(CalledOnValidThread());
|
| +
|
| + if (!decisions_)
|
| + return false;
|
| +
|
| + return decisions_->HasAllowedOrDeniedCert(url);
|
| +}
|
| +
|
| +void SSLHostState::Clear() {
|
| + if (!decisions_)
|
| + return;
|
| +
|
| + decisions_->Clear();
|
| }
|
|
|
| net::CertPolicy::Judgment SSLHostState::QueryPolicy(net::X509Certificate* cert,
|
| - const std::string& host,
|
| + const GURL& url,
|
| net::CertStatus error) {
|
| DCHECK(CalledOnValidThread());
|
|
|
| - return cert_policy_for_host_[host].Check(cert, error);
|
| + if (!decisions_)
|
| + return net::CertPolicy::Judgment::UNKNOWN;
|
| +
|
| + return decisions_->QueryPolicy(url, cert, error);
|
| }
|
|
|
| } // namespace content
|
|
|