blob: f8a063bdd5e432346d5c85fd82b356990f46daf7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ssl/ssl_host_state.h"
#include "base/logging.h"
namespace {
static const char kDot = '.';
static bool IsIntranetHost(const std::string& host) {
const size_t dot = host.find(kDot);
return dot == std::string::npos || dot == host.length() - 1;
}
} // namespace
SSLHostState::SSLHostState() {
}
SSLHostState::~SSLHostState() {
}
void SSLHostState::MarkHostAsBroken(const std::string& host) {
DCHECK(CalledOnValidThread());
broken_hosts_.insert(host);
}
bool SSLHostState::DidMarkHostAsBroken(const std::string& host) {
DCHECK(CalledOnValidThread());
// CAs issue certificate for intranet hosts to everyone. Therefore, we always
// treat intranet hosts as broken.
if (IsIntranetHost(host))
return true;
return (broken_hosts_.find(host) != broken_hosts_.end());
}
void SSLHostState::DenyCertForHost(net::X509Certificate* cert,
const std::string& host) {
DCHECK(CalledOnValidThread());
// Remember that we don't like this cert for this host.
cert_policy_for_host_[host].Deny(cert);
}
void SSLHostState::AllowCertForHost(net::X509Certificate* cert,
const std::string& host) {
DCHECK(CalledOnValidThread());
// Remember that we do like this cert for this host.
cert_policy_for_host_[host].Allow(cert);
}
net::X509Certificate::Policy::Judgment SSLHostState::QueryPolicy(
net::X509Certificate* cert, const std::string& host) {
DCHECK(CalledOnValidThread());
return cert_policy_for_host_[host].Check(cert);
}
void SSLHostState::AllowMixedContentForHost(const std::string& host) {
DCHECK(CalledOnValidThread());
allow_mixed_content_for_host_.insert(host);
}
bool SSLHostState::DidAllowMixedContentForHost(const std::string& host) {
DCHECK(CalledOnValidThread());
return (allow_mixed_content_for_host_.find(host) !=
allow_mixed_content_for_host_.end());
}
|