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

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

Issue 2066603004: Return enum from TransportSecurityState::CheckPublicKeyPins (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Set CERT_STATUS_PINNED_KEY_MISSING Created 4 years, 6 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
« no previous file with comments | « net/http/http_security_headers_unittest.cc ('k') | net/http/transport_security_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 bool HasNext() const { return iterator_ != end_; } 96 bool HasNext() const { return iterator_ != end_; }
97 void Advance() { ++iterator_; } 97 void Advance() { ++iterator_; }
98 const std::string& hostname() const { return iterator_->first; } 98 const std::string& hostname() const { return iterator_->first; }
99 const STSState& domain_state() const { return iterator_->second; } 99 const STSState& domain_state() const { return iterator_->second; }
100 100
101 private: 101 private:
102 std::map<std::string, STSState>::const_iterator iterator_; 102 std::map<std::string, STSState>::const_iterator iterator_;
103 std::map<std::string, STSState>::const_iterator end_; 103 std::map<std::string, STSState>::const_iterator end_;
104 }; 104 };
105 105
106 // PKPStatus describes the result of a pinning check.
107 enum class PKPStatus {
108 // Pinning was enabled and the necessary pins were not present.
109 VIOLATED,
110
111 // Pinning was not enabled, or pinning was enabled and the certificate
112 // satisfied the pins.
113 OK,
114
115 // Pinning was enabled and the certificate did not satisfy the pins, but the
116 // violation was ignored due to local policy, such as a local trust anchor.
117 BYPASSED,
118 };
119
106 // A PKPState describes the public key pinning state. 120 // A PKPState describes the public key pinning state.
107 class NET_EXPORT PKPState { 121 class NET_EXPORT PKPState {
108 public: 122 public:
109 PKPState(); 123 PKPState();
110 PKPState(const PKPState& other); 124 PKPState(const PKPState& other);
111 ~PKPState(); 125 ~PKPState();
112 126
113 // The absolute time (UTC) when the |spki_hashes| (and other state) were 127 // The absolute time (UTC) when the |spki_hashes| (and other state) were
114 // observed. 128 // observed.
115 base::Time last_observed; 129 base::Time last_observed;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 TransportSecurityState(); 258 TransportSecurityState();
245 ~TransportSecurityState(); 259 ~TransportSecurityState();
246 260
247 // These functions search for static and dynamic STS and PKP states, and 261 // These functions search for static and dynamic STS and PKP states, and
248 // invoke the functions of the same name on them. These functions are the 262 // invoke the functions of the same name on them. These functions are the
249 // primary public interface; direct access to STS and PKP states is best 263 // primary public interface; direct access to STS and PKP states is best
250 // left to tests. The caller needs to handle the optional pinning override 264 // left to tests. The caller needs to handle the optional pinning override
251 // when is_issued_by_known_root is false. 265 // when is_issued_by_known_root is false.
252 bool ShouldSSLErrorsBeFatal(const std::string& host); 266 bool ShouldSSLErrorsBeFatal(const std::string& host);
253 bool ShouldUpgradeToSSL(const std::string& host); 267 bool ShouldUpgradeToSSL(const std::string& host);
254 bool CheckPublicKeyPins(const HostPortPair& host_port_pair, 268 PKPStatus CheckPublicKeyPins(
255 bool is_issued_by_known_root, 269 const HostPortPair& host_port_pair,
256 const HashValueVector& hashes, 270 bool is_issued_by_known_root,
257 const X509Certificate* served_certificate_chain, 271 const HashValueVector& hashes,
258 const X509Certificate* validated_certificate_chain, 272 const X509Certificate* served_certificate_chain,
259 const PublicKeyPinReportStatus report_status, 273 const X509Certificate* validated_certificate_chain,
260 std::string* failure_log); 274 const PublicKeyPinReportStatus report_status,
275 std::string* failure_log);
261 bool HasPublicKeyPins(const std::string& host); 276 bool HasPublicKeyPins(const std::string& host);
262 277
263 // Assign a |Delegate| for persisting the transport security state. If 278 // Assign a |Delegate| for persisting the transport security state. If
264 // |NULL|, state will not be persisted. The caller retains 279 // |NULL|, state will not be persisted. The caller retains
265 // ownership of |delegate|. 280 // ownership of |delegate|.
266 // Note: This is only used for serializing/deserializing the 281 // Note: This is only used for serializing/deserializing the
267 // TransportSecurityState. 282 // TransportSecurityState.
268 void SetDelegate(Delegate* delegate); 283 void SetDelegate(Delegate* delegate);
269 284
270 void SetReportSender(ReportSenderInterface* report_sender); 285 void SetReportSender(ReportSenderInterface* report_sender);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 // representation of first-class DomainStates, and exposing the preloads 411 // representation of first-class DomainStates, and exposing the preloads
397 // to the caller with |GetStaticDomainState|. 412 // to the caller with |GetStaticDomainState|.
398 static void ReportUMAOnPinFailure(const std::string& host); 413 static void ReportUMAOnPinFailure(const std::string& host);
399 414
400 // IsBuildTimely returns true if the current build is new enough ensure that 415 // IsBuildTimely returns true if the current build is new enough ensure that
401 // built in security information (i.e. HSTS preloading and pinning 416 // built in security information (i.e. HSTS preloading and pinning
402 // information) is timely. 417 // information) is timely.
403 static bool IsBuildTimely(); 418 static bool IsBuildTimely();
404 419
405 // Helper method for actually checking pins. 420 // Helper method for actually checking pins.
406 bool CheckPublicKeyPinsImpl( 421 PKPStatus CheckPublicKeyPinsImpl(
407 const HostPortPair& host_port_pair, 422 const HostPortPair& host_port_pair,
408 bool is_issued_by_known_root, 423 bool is_issued_by_known_root,
409 const HashValueVector& hashes, 424 const HashValueVector& hashes,
410 const X509Certificate* served_certificate_chain, 425 const X509Certificate* served_certificate_chain,
411 const X509Certificate* validated_certificate_chain, 426 const X509Certificate* validated_certificate_chain,
412 const PublicKeyPinReportStatus report_status, 427 const PublicKeyPinReportStatus report_status,
413 std::string* failure_log); 428 std::string* failure_log);
414 429
415 // If a Delegate is present, notify it that the internal state has 430 // If a Delegate is present, notify it that the internal state has
416 // changed. 431 // changed.
(...skipping 20 matching lines...) Expand all
437 void EnableSTSHost(const std::string& host, const STSState& state); 452 void EnableSTSHost(const std::string& host, const STSState& state);
438 void EnablePKPHost(const std::string& host, const PKPState& state); 453 void EnablePKPHost(const std::string& host, const PKPState& state);
439 454
440 // Returns true if a request to |host_port_pair| with the given 455 // Returns true if a request to |host_port_pair| with the given
441 // SubjectPublicKeyInfo |hashes| satisfies the pins in |pkp_state|, 456 // SubjectPublicKeyInfo |hashes| satisfies the pins in |pkp_state|,
442 // and false otherwise. If a violation is found and reporting is 457 // and false otherwise. If a violation is found and reporting is
443 // configured (i.e. there is a report URI in |pkp_state| and 458 // configured (i.e. there is a report URI in |pkp_state| and
444 // |report_status| says to), this method sends an HPKP violation 459 // |report_status| says to), this method sends an HPKP violation
445 // report containing |served_certificate_chain| and 460 // report containing |served_certificate_chain| and
446 // |validated_certificate_chain|. 461 // |validated_certificate_chain|.
447 bool CheckPinsAndMaybeSendReport( 462 PKPStatus CheckPinsAndMaybeSendReport(
448 const HostPortPair& host_port_pair, 463 const HostPortPair& host_port_pair,
449 bool is_issued_by_known_root, 464 bool is_issued_by_known_root,
450 const TransportSecurityState::PKPState& pkp_state, 465 const TransportSecurityState::PKPState& pkp_state,
451 const HashValueVector& hashes, 466 const HashValueVector& hashes,
452 const X509Certificate* served_certificate_chain, 467 const X509Certificate* served_certificate_chain,
453 const X509Certificate* validated_certificate_chain, 468 const X509Certificate* validated_certificate_chain,
454 const TransportSecurityState::PublicKeyPinReportStatus report_status, 469 const TransportSecurityState::PublicKeyPinReportStatus report_status,
455 std::string* failure_log); 470 std::string* failure_log);
456 471
457 // Returns true and updates |*expect_ct_result| iff there is a static 472 // Returns true and updates |*expect_ct_result| iff there is a static
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 // rate-limiting. 509 // rate-limiting.
495 ExpiringCache<std::string, bool, base::TimeTicks, std::less<base::TimeTicks>> 510 ExpiringCache<std::string, bool, base::TimeTicks, std::less<base::TimeTicks>>
496 sent_reports_cache_; 511 sent_reports_cache_;
497 512
498 DISALLOW_COPY_AND_ASSIGN(TransportSecurityState); 513 DISALLOW_COPY_AND_ASSIGN(TransportSecurityState);
499 }; 514 };
500 515
501 } // namespace net 516 } // namespace net
502 517
503 #endif // NET_HTTP_TRANSPORT_SECURITY_STATE_H_ 518 #endif // NET_HTTP_TRANSPORT_SECURITY_STATE_H_
OLDNEW
« no previous file with comments | « net/http/http_security_headers_unittest.cc ('k') | net/http/transport_security_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698