Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: net/http/transport_security_state.h

Issue 103803012: Make HSTS headers not clobber preloaded pins. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and updated comment. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef NET_HTTP_TRANSPORT_SECURITY_STATE_H_ 5 #ifndef NET_HTTP_TRANSPORT_SECURITY_STATE_H_
6 #define NET_HTTP_TRANSPORT_SECURITY_STATE_H_ 6 #define NET_HTTP_TRANSPORT_SECURITY_STATE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 public: 54 public:
55 enum UpgradeMode { 55 enum UpgradeMode {
56 // These numbers must match those in hsts_view.js, function modeToString. 56 // These numbers must match those in hsts_view.js, function modeToString.
57 MODE_FORCE_HTTPS = 0, 57 MODE_FORCE_HTTPS = 0,
58 MODE_DEFAULT = 1, 58 MODE_DEFAULT = 1,
59 }; 59 };
60 60
61 DomainState(); 61 DomainState();
62 ~DomainState(); 62 ~DomainState();
63 63
64 struct STSState {
65 // The absolute time (UTC) when the |upgrade_mode| (and other state) was
66 // observed.
67 base::Time last_observed;
68
69 // The absolute time (UTC) when the |upgrade_mode|, if set to
70 // UPGRADE_ALWAYS, downgrades to UPGRADE_NEVER.
71 base::Time expiry;
72
73 UpgradeMode upgrade_mode;
74
75 // Are subdomains subject to this policy state?
76 bool include_subdomains;
77 };
78
79 struct PKPState {
80 // The absolute time (UTC) when the |spki_hashes| (and other state) were
81 // observed.
82 base::Time last_observed;
83
84 // The absolute time (UTC) when the |spki_hashes| expire.
85 base::Time expiry;
86
87 // Optional; hashes of pinned SubjectPublicKeyInfos.
88 HashValueVector spki_hashes;
89
90 // Optional; hashes of static known-bad SubjectPublicKeyInfos which MUST
91 // NOT intersect with the set of SPKIs in the TLS server's certificate
92 // chain.
93 HashValueVector bad_spki_hashes;
94
95 // Are subdomains subject to this policy state?
96 bool include_subdomains;
97 };
98
64 // Takes a set of SubjectPublicKeyInfo |hashes| and returns true if: 99 // Takes a set of SubjectPublicKeyInfo |hashes| and returns true if:
65 // 1) |bad_static_spki_hashes| does not intersect |hashes|; AND 100 // 1) |bad_static_spki_hashes| does not intersect |hashes|; AND
66 // 2) Both |static_spki_hashes| and |dynamic_spki_hashes| are empty 101 // 2) Both |static_spki_hashes| and |dynamic_spki_hashes| are empty
67 // or at least one of them intersects |hashes|. 102 // or at least one of them intersects |hashes|.
68 // 103 //
69 // |{dynamic,static}_spki_hashes| contain trustworthy public key hashes, 104 // |{dynamic,static}_spki_hashes| contain trustworthy public key hashes,
70 // any one of which is sufficient to validate the certificate chain in 105 // any one of which is sufficient to validate the certificate chain in
71 // question. The public keys could be of a root CA, intermediate CA, or 106 // question. The public keys could be of a root CA, intermediate CA, or
72 // leaf certificate, depending on the security vs. disaster recovery 107 // leaf certificate, depending on the security vs. disaster recovery
73 // tradeoff selected. (Pinning only to leaf certifiates increases 108 // tradeoff selected. (Pinning only to leaf certifiates increases
(...skipping 12 matching lines...) Expand all
86 121
87 // ShouldUpgradeToSSL returns true iff, given the |mode| of this 122 // ShouldUpgradeToSSL returns true iff, given the |mode| of this
88 // DomainState, HTTP requests should be internally redirected to HTTPS 123 // DomainState, HTTP requests should be internally redirected to HTTPS
89 // (also if the "ws" WebSocket request should be upgraded to "wss") 124 // (also if the "ws" WebSocket request should be upgraded to "wss")
90 bool ShouldUpgradeToSSL() const; 125 bool ShouldUpgradeToSSL() const;
91 126
92 // ShouldSSLErrorsBeFatal returns true iff HTTPS errors should cause 127 // ShouldSSLErrorsBeFatal returns true iff HTTPS errors should cause
93 // hard-fail behavior (e.g. if HSTS is set for the domain) 128 // hard-fail behavior (e.g. if HSTS is set for the domain)
94 bool ShouldSSLErrorsBeFatal() const; 129 bool ShouldSSLErrorsBeFatal() const;
95 130
96 UpgradeMode upgrade_mode; 131 bool has_static_sts;
132 STSState static_sts;
133 STSState dynamic_sts;
97 134
98 // The absolute time (UTC) when the |upgrade_mode| was observed. 135 bool has_static_pkp;
136 // Unless both |{dynamic,static}_hpkp_state.spki_hashes| are empty, at least
137 // one of them MUST intersect with the set of SPKIs in the TLS server's
138 // certificate chain.
99 // 139 //
100 // TODO(palmer): Perhaps static entries should have an "observed" time. 140 // |dynamic_hpkp_state| takes precedence over |static_hpkp_state|. That is,
101 base::Time sts_observed; 141 // |IsChainOfPublicKeysPermitted| first checks dynamic state and then checks
102 142 // static state.
Ryan Sleevi 2014/03/07 01:39:19 Let's expand/reword this comment. // When checkin
palmer 2014/03/14 21:33:39 Well, wouldn't it be a good idea to allow site ope
Ryan Sleevi 2014/03/14 21:55:29 Yes, but your comment is unclear on that, which is
103 // The absolute time (UTC) when the |dynamic_spki_hashes| (and other 143 PKPState static_pkp;
104 // |dynamic_*| state) were observed. 144 PKPState dynamic_pkp;
105 //
106 // TODO(palmer): Perhaps static entries should have an "observed" time.
107 base::Time pkp_observed;
108
109 // The absolute time (UTC) when the |upgrade_mode|, if set to
110 // UPGRADE_ALWAYS, downgrades to UPGRADE_NEVER.
111 base::Time upgrade_expiry;
112
113 // Are subdomains subject to this DomainState, for the purposes of
114 // upgrading to HTTPS?
115 bool sts_include_subdomains;
116
117 // Are subdomains subject to this DomainState, for the purposes of
118 // Pin Validation?
119 bool pkp_include_subdomains;
120
121 // Optional; hashes of static pinned SubjectPublicKeyInfos. Unless both
122 // are empty, at least one of |static_spki_hashes| and
123 // |dynamic_spki_hashes| MUST intersect with the set of SPKIs in the TLS
124 // server's certificate chain.
125 //
126 // |dynamic_spki_hashes| take precedence over |static_spki_hashes|.
127 // That is, |IsChainOfPublicKeysPermitted| first checks dynamic pins and
128 // then checks static pins.
129 HashValueVector static_spki_hashes;
130
131 // Optional; hashes of dynamically pinned SubjectPublicKeyInfos.
132 HashValueVector dynamic_spki_hashes;
133
134 // The absolute time (UTC) when the |dynamic_spki_hashes| expire.
135 base::Time dynamic_spki_hashes_expiry;
136
137 // Optional; hashes of static known-bad SubjectPublicKeyInfos which
138 // MUST NOT intersect with the set of SPKIs in the TLS server's
139 // certificate chain.
140 HashValueVector bad_static_spki_hashes;
141 145
142 // The following members are not valid when stored in |enabled_hosts_|: 146 // The following members are not valid when stored in |enabled_hosts_|:
143 147
144 // The domain which matched during a search for this DomainState entry. 148 // The domain which matched during a search for this DomainState entry.
145 // Updated by |GetDomainState|, |GetDynamicDomainState|, and 149 // Updated by |GetDomainState|, |GetDynamicDomainState|, and
146 // |GetStaticDomainState|. 150 // |GetStaticDomainState|.
147 std::string domain; 151 std::string domain;
148 }; 152 };
149 153
150 class NET_EXPORT Iterator { 154 class NET_EXPORT Iterator {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 DomainStateMap enabled_hosts_; 329 DomainStateMap enabled_hosts_;
326 330
327 Delegate* delegate_; 331 Delegate* delegate_;
328 332
329 DISALLOW_COPY_AND_ASSIGN(TransportSecurityState); 333 DISALLOW_COPY_AND_ASSIGN(TransportSecurityState);
330 }; 334 };
331 335
332 } // namespace net 336 } // namespace net
333 337
334 #endif // NET_HTTP_TRANSPORT_SECURITY_STATE_H_ 338 #endif // NET_HTTP_TRANSPORT_SECURITY_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698