OLD | NEW |
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> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/feature_list.h" | 14 #include "base/feature_list.h" |
15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
18 #include "base/threading/non_thread_safe.h" | 18 #include "base/threading/thread_checker.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "net/base/expiring_cache.h" | 20 #include "net/base/expiring_cache.h" |
21 #include "net/base/hash_value.h" | 21 #include "net/base/hash_value.h" |
22 #include "net/base/net_export.h" | 22 #include "net/base/net_export.h" |
23 #include "net/cert/signed_certificate_timestamp_and_status.h" | 23 #include "net/cert/signed_certificate_timestamp_and_status.h" |
24 #include "net/http/transport_security_state_source.h" | 24 #include "net/http/transport_security_state_source.h" |
25 #include "url/gurl.h" | 25 #include "url/gurl.h" |
26 | 26 |
27 namespace net { | 27 namespace net { |
28 | 28 |
(...skipping 11 matching lines...) Expand all Loading... |
40 // Tracks which hosts have enabled strict transport security and/or public | 40 // Tracks which hosts have enabled strict transport security and/or public |
41 // key pins. | 41 // key pins. |
42 // | 42 // |
43 // This object manages the in-memory store. Register a Delegate with | 43 // This object manages the in-memory store. Register a Delegate with |
44 // |SetDelegate| to persist the state to disk. | 44 // |SetDelegate| to persist the state to disk. |
45 // | 45 // |
46 // HTTP strict transport security (HSTS) is defined in | 46 // HTTP strict transport security (HSTS) is defined in |
47 // http://tools.ietf.org/html/ietf-websec-strict-transport-sec, and | 47 // http://tools.ietf.org/html/ietf-websec-strict-transport-sec, and |
48 // HTTP-based dynamic public key pinning (HPKP) is defined in | 48 // HTTP-based dynamic public key pinning (HPKP) is defined in |
49 // http://tools.ietf.org/html/ietf-websec-key-pinning. | 49 // http://tools.ietf.org/html/ietf-websec-key-pinning. |
50 class NET_EXPORT TransportSecurityState | 50 class NET_EXPORT TransportSecurityState { |
51 : NON_EXPORTED_BASE(public base::NonThreadSafe) { | |
52 public: | 51 public: |
53 class NET_EXPORT Delegate { | 52 class NET_EXPORT Delegate { |
54 public: | 53 public: |
55 // This function may not block and may be called with internal locks held. | 54 // This function may not block and may be called with internal locks held. |
56 // Thus it must not reenter the TransportSecurityState object. | 55 // Thus it must not reenter the TransportSecurityState object. |
57 virtual void StateIsDirty(TransportSecurityState* state) = 0; | 56 virtual void StateIsDirty(TransportSecurityState* state) = 0; |
58 | 57 |
59 protected: | 58 protected: |
60 virtual ~Delegate() {} | 59 virtual ~Delegate() {} |
61 }; | 60 }; |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 // SetExpectCTReporter). | 552 // SetExpectCTReporter). |
554 // | 553 // |
555 // The header can also have the value "preload", indicating that the site | 554 // The header can also have the value "preload", indicating that the site |
556 // wants to opt-in to the static report-only version of Expect-CT. If the | 555 // wants to opt-in to the static report-only version of Expect-CT. If the |
557 // given host is present on the preload list and the build is timely and the | 556 // given host is present on the preload list and the build is timely and the |
558 // connection is not CT-compliant, then a report will be sent. | 557 // connection is not CT-compliant, then a report will be sent. |
559 void ProcessExpectCTHeader(const std::string& value, | 558 void ProcessExpectCTHeader(const std::string& value, |
560 const HostPortPair& host_port_pair, | 559 const HostPortPair& host_port_pair, |
561 const SSLInfo& ssl_info); | 560 const SSLInfo& ssl_info); |
562 | 561 |
| 562 void AssertCalledOnValidThread() const { |
| 563 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 564 } |
| 565 |
563 // For unit tests only. Causes CheckCTRequirements() to return | 566 // For unit tests only. Causes CheckCTRequirements() to return |
564 // CT_REQUIREMENTS_NOT_MET (if |*required| is true) or CT_REQUIREMENTS_MET (if | 567 // CT_REQUIREMENTS_NOT_MET (if |*required| is true) or CT_REQUIREMENTS_MET (if |
565 // |*required| is false) for non-compliant connections by default (that is, | 568 // |*required| is false) for non-compliant connections by default (that is, |
566 // unless a RequireCTDelegate overrides). Set to nullptr to reset. | 569 // unless a RequireCTDelegate overrides). Set to nullptr to reset. |
567 static void SetShouldRequireCTForTesting(bool* required); | 570 static void SetShouldRequireCTForTesting(bool* required); |
568 | 571 |
569 // For unit tests only. Clears the caches that deduplicate sent HPKP and | 572 // For unit tests only. Clears the caches that deduplicate sent HPKP and |
570 // Expect-CT reports. | 573 // Expect-CT reports. |
571 void ClearReportCachesForTesting(); | 574 void ClearReportCachesForTesting(); |
572 | 575 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 | 703 |
701 ExpectCTReporter* expect_ct_reporter_ = nullptr; | 704 ExpectCTReporter* expect_ct_reporter_ = nullptr; |
702 | 705 |
703 RequireCTDelegate* require_ct_delegate_ = nullptr; | 706 RequireCTDelegate* require_ct_delegate_ = nullptr; |
704 | 707 |
705 // Keeps track of reports that have been sent recently for | 708 // Keeps track of reports that have been sent recently for |
706 // rate-limiting. | 709 // rate-limiting. |
707 ReportCache sent_hpkp_reports_cache_; | 710 ReportCache sent_hpkp_reports_cache_; |
708 ReportCache sent_expect_ct_reports_cache_; | 711 ReportCache sent_expect_ct_reports_cache_; |
709 | 712 |
| 713 THREAD_CHECKER(thread_checker_); |
| 714 |
710 DISALLOW_COPY_AND_ASSIGN(TransportSecurityState); | 715 DISALLOW_COPY_AND_ASSIGN(TransportSecurityState); |
711 }; | 716 }; |
712 | 717 |
713 } // namespace net | 718 } // namespace net |
714 | 719 |
715 #endif // NET_HTTP_TRANSPORT_SECURITY_STATE_H_ | 720 #endif // NET_HTTP_TRANSPORT_SECURITY_STATE_H_ |
OLD | NEW |