Chromium Code Reviews| 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/non_thread_safe.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/http/transport_security_state_source.h" | 24 #include "net/http/transport_security_state_source.h" |
| 24 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 25 | 26 |
| 26 namespace net { | 27 namespace net { |
| 27 | 28 |
| 28 class HostPortPair; | 29 class HostPortPair; |
| 29 class SSLInfo; | 30 class SSLInfo; |
| 30 class X509Certificate; | 31 class X509Certificate; |
| 31 | 32 |
| 32 void NET_EXPORT_PRIVATE SetTransportSecurityStateSourceForTesting( | 33 void NET_EXPORT_PRIVATE SetTransportSecurityStateSourceForTesting( |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 }; | 304 }; |
| 304 | 305 |
| 305 // An interface for building and asynchronously sending reports when a | 306 // An interface for building and asynchronously sending reports when a |
| 306 // site expects valid Certificate Transparency information but it | 307 // site expects valid Certificate Transparency information but it |
| 307 // wasn't supplied. | 308 // wasn't supplied. |
| 308 class NET_EXPORT ExpectCTReporter { | 309 class NET_EXPORT ExpectCTReporter { |
| 309 public: | 310 public: |
| 310 // Called when the host in |host_port_pair| has opted in to have | 311 // Called when the host in |host_port_pair| has opted in to have |
| 311 // reports about Expect CT policy violations sent to |report_uri|, | 312 // reports about Expect CT policy violations sent to |report_uri|, |
| 312 // and such a violation has occurred. | 313 // and such a violation has occurred. |
| 313 virtual void OnExpectCTFailed(const net::HostPortPair& host_port_pair, | 314 virtual void OnExpectCTFailed( |
| 314 const GURL& report_uri, | 315 const net::HostPortPair& host_port_pair, |
| 315 const net::SSLInfo& ssl_info) = 0; | 316 const GURL& report_uri, |
| 317 const X509Certificate* served_certificate_chain, | |
| 318 const X509Certificate* validated_certificate_chain, | |
| 319 const SignedCertificateTimestampAndStatusList& | |
| 320 signed_certificate_timestamps) = 0; | |
| 316 | 321 |
| 317 protected: | 322 protected: |
| 318 virtual ~ExpectCTReporter() {} | 323 virtual ~ExpectCTReporter() {} |
| 319 }; | 324 }; |
| 320 | 325 |
| 321 // Indicates whether or not a public key pin check should send a | 326 // Indicates whether or not a public key pin check should send a |
| 322 // report if a violation is detected. | 327 // report if a violation is detected. |
| 323 enum PublicKeyPinReportStatus { ENABLE_PIN_REPORTS, DISABLE_PIN_REPORTS }; | 328 enum PublicKeyPinReportStatus { ENABLE_PIN_REPORTS, DISABLE_PIN_REPORTS }; |
| 324 | 329 |
| 330 // Indicates whether or not an Expect-CT check should send a report if a | |
| 331 // violation is detected. | |
| 332 enum ExpectCTReportStatus { | |
| 333 ENABLE_EXPECT_CT_REPORTS, | |
| 334 DISABLE_EXPECT_CT_REPORTS | |
| 335 }; | |
| 336 | |
| 325 // Feature that controls whether Expect-CT HTTP headers are parsed, processed, | 337 // Feature that controls whether Expect-CT HTTP headers are parsed, processed, |
| 326 // and stored. | 338 // and stored. |
| 327 static const base::Feature kDynamicExpectCTFeature; | 339 static const base::Feature kDynamicExpectCTFeature; |
| 328 | 340 |
| 329 TransportSecurityState(); | 341 TransportSecurityState(); |
| 330 ~TransportSecurityState(); | 342 ~TransportSecurityState(); |
| 331 | 343 |
| 332 // These functions search for static and dynamic STS and PKP states, and | 344 // These functions search for static and dynamic STS and PKP states, and |
| 333 // invoke the functions of the same name on them. These functions are the | 345 // invoke the functions of the same name on them. These functions are the |
| 334 // primary public interface; direct access to STS and PKP states is best | 346 // primary public interface; direct access to STS and PKP states is best |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 359 // for OCSP responses behind MITM proxies are not useful to site owners. | 371 // for OCSP responses behind MITM proxies are not useful to site owners. |
| 360 void CheckExpectStaple(const HostPortPair& host_port_pair, | 372 void CheckExpectStaple(const HostPortPair& host_port_pair, |
| 361 const SSLInfo& ssl_info, | 373 const SSLInfo& ssl_info, |
| 362 base::StringPiece ocsp_response); | 374 base::StringPiece ocsp_response); |
| 363 | 375 |
| 364 // Returns true if connections to |host|, using the validated certificate | 376 // Returns true if connections to |host|, using the validated certificate |
| 365 // |validated_certificate_chain|, are expected to be accompanied with | 377 // |validated_certificate_chain|, are expected to be accompanied with |
| 366 // valid Certificate Transparency information that complies with the | 378 // valid Certificate Transparency information that complies with the |
| 367 // connection's CTPolicyEnforcer. | 379 // connection's CTPolicyEnforcer. |
| 368 // | 380 // |
| 381 // This method checks Expect-CT state for |host| if |issued_by_known_root| is | |
| 382 // true. If Expect-CT is configured for |host| and the connection is not | |
| 383 // compliant and |report_status| is ENABLE_EXPECT_CT_REPORTS, then a report | |
| 384 // will be sent. | |
|
mattm
2017/05/02 23:32:52
It seems weird that a method called "ShouldRequire
estark
2017/05/03 00:13:20
Yeah, I thought about that and hoped that the extr
mattm
2017/05/03 00:37:07
(a) sgtm too. CheckCTRequirements seems reasonable
estark
2017/05/04 01:18:30
Done.
| |
| 385 // | |
| 369 // The behavior may be further be altered by setting a RequireCTDelegate | 386 // The behavior may be further be altered by setting a RequireCTDelegate |
| 370 // via |SetRequireCTDelegate()|. | 387 // via |SetRequireCTDelegate()|. |
| 371 bool ShouldRequireCT(const std::string& host, | 388 bool ShouldRequireCT(const net::HostPortPair& host_port_pair, |
| 389 bool is_issued_by_known_root, | |
| 390 const HashValueVector& public_key_hashes, | |
| 372 const X509Certificate* validated_certificate_chain, | 391 const X509Certificate* validated_certificate_chain, |
| 373 const HashValueVector& hashes); | 392 const X509Certificate* served_certificate_chain, |
|
mattm
2017/05/02 23:32:52
confusing that the order is different here than in
estark
2017/05/04 01:18:30
Done (flipped the order in OnExpectCTFailed)
| |
| 393 const SignedCertificateTimestampAndStatusList& | |
| 394 signed_certificate_timestamps, | |
| 395 const ExpectCTReportStatus report_status); | |
| 374 | 396 |
| 375 // Assign a |Delegate| for persisting the transport security state. If | 397 // Assign a |Delegate| for persisting the transport security state. If |
| 376 // |NULL|, state will not be persisted. The caller retains | 398 // |NULL|, state will not be persisted. The caller retains |
| 377 // ownership of |delegate|. | 399 // ownership of |delegate|. |
| 378 // Note: This is only used for serializing/deserializing the | 400 // Note: This is only used for serializing/deserializing the |
| 379 // TransportSecurityState. | 401 // TransportSecurityState. |
| 380 void SetDelegate(Delegate* delegate); | 402 void SetDelegate(Delegate* delegate); |
| 381 | 403 |
| 382 void SetReportSender(ReportSenderInterface* report_sender); | 404 void SetReportSender(ReportSenderInterface* report_sender); |
| 383 | 405 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 655 // rate-limiting. | 677 // rate-limiting. |
| 656 ExpiringCache<std::string, bool, base::TimeTicks, std::less<base::TimeTicks>> | 678 ExpiringCache<std::string, bool, base::TimeTicks, std::less<base::TimeTicks>> |
| 657 sent_reports_cache_; | 679 sent_reports_cache_; |
| 658 | 680 |
| 659 DISALLOW_COPY_AND_ASSIGN(TransportSecurityState); | 681 DISALLOW_COPY_AND_ASSIGN(TransportSecurityState); |
| 660 }; | 682 }; |
| 661 | 683 |
| 662 } // namespace net | 684 } // namespace net |
| 663 | 685 |
| 664 #endif // NET_HTTP_TRANSPORT_SECURITY_STATE_H_ | 686 #endif // NET_HTTP_TRANSPORT_SECURITY_STATE_H_ |
| OLD | NEW |