Index: net/http/transport_security_state.h |
diff --git a/net/http/transport_security_state.h b/net/http/transport_security_state.h |
index 2cbd5ef52ba7a34e6af43d880d323f6973cab36e..cc12d8e1fc80dc554645036bd71261a52c3ef98f 100644 |
--- a/net/http/transport_security_state.h |
+++ b/net/http/transport_security_state.h |
@@ -18,6 +18,8 @@ |
#include "net/cert/x509_cert_types.h" |
#include "net/cert/x509_certificate.h" |
+class GURL; |
+ |
namespace net { |
class SSLInfo; |
@@ -45,9 +47,6 @@ class NET_EXPORT TransportSecurityState |
virtual ~Delegate() {} |
}; |
- TransportSecurityState(); |
- ~TransportSecurityState(); |
- |
// A DomainState describes the transport security state (required upgrade |
// to HTTPS, and/or any public key pins). |
// |
@@ -113,6 +112,10 @@ class NET_EXPORT TransportSecurityState |
// The domain which matched during a search for this DomainState entry. |
// Updated by |GetDynamicDomainState| and |GetStaticDomainState|. |
std::string domain; |
+ |
+ // Optional; a uri-reference indicating where reports should be |
+ // sent when this pin is violated. |
+ std::string report_uri; |
}; |
// Takes a set of SubjectPublicKeyInfo |hashes| and returns true if: |
@@ -166,15 +169,59 @@ class NET_EXPORT TransportSecurityState |
std::map<std::string, DomainState>::const_iterator end_; |
}; |
+ class NET_EXPORT Reporter { |
+ public: |
+ virtual ~Reporter() {} |
+ |
+ // Returns true if a violation report should be sent for the host in |
+ // the given |pkp_state|, and returns the report destination URI in |
+ // |report_uri|. Returns false if a report should not be sent. |
+ virtual bool GetHPKPReportUri(const DomainState::PKPState& pkp_state, |
+ GURL* report_uri) = 0; |
+ |
+ // Builds a serialized HPKP violation report in |
+ // |serialized_report|. Returns true on success and false on |
+ // failure. |
+ virtual bool BuildHPKPReport( |
+ const std::string& hostname, |
+ uint16_t port, |
+ const base::Time& expiry, |
+ bool include_subdomains, |
+ const std::string& effective_hostname, |
+ const scoped_refptr<X509Certificate>& served_certificate_chain, |
+ const scoped_refptr<X509Certificate>& validated_certificate_chain, |
+ const HashValueVector& spki_hashes, |
+ std::string* serialized_report) = 0; |
+ |
+ // Sends the given serialized |report| to |report_uri|. |
+ virtual void SendHPKPReport(const GURL& report_uri, |
+ const std::string& report) = 0; |
+ }; |
+ |
+ // Indicates whether or not a public key pin check should send a |
+ // report if a violation is detected. |
+ enum PublicKeyPinReportStatus { |
+ DO_NOT_SEND_PUBLIC_KEY_PIN_REPORT, |
+ SEND_PUBLIC_KEY_PIN_REPORT |
+ }; |
+ |
+ TransportSecurityState(); |
+ ~TransportSecurityState(); |
+ |
// These functions search for static and dynamic DomainStates, and invoke the |
// functions of the same name on them. These functions are the primary public |
// interface; direct access to DomainStates is best left to tests. |
bool ShouldSSLErrorsBeFatal(const std::string& host); |
bool ShouldUpgradeToSSL(const std::string& host); |
- bool CheckPublicKeyPins(const std::string& host, |
- bool is_issued_by_known_root, |
- const HashValueVector& hashes, |
- std::string* failure_log); |
+ bool CheckPublicKeyPins( |
+ const std::string& host, |
+ bool is_issued_by_known_root, |
+ const HashValueVector& hashes, |
+ uint16_t port, |
+ const scoped_refptr<X509Certificate>& served_certificate_chain, |
+ const scoped_refptr<X509Certificate>& validated_certificate_chain, |
+ const PublicKeyPinReportStatus report_status, |
+ std::string* failure_log); |
bool HasPublicKeyPins(const std::string& host); |
// Assign a |Delegate| for persisting the transport security state. If |
@@ -184,6 +231,8 @@ class NET_EXPORT TransportSecurityState |
// TransportSecurityState. |
void SetDelegate(Delegate* delegate); |
+ void SetReporter(Reporter* reporter); |
+ |
// Clears all dynamic data (e.g. HSTS and HPKP data). |
// |
// Does NOT persist changes using the Delegate, as this function is only |
@@ -254,7 +303,8 @@ class NET_EXPORT TransportSecurityState |
void AddHPKP(const std::string& host, |
const base::Time& expiry, |
bool include_subdomains, |
- const HashValueVector& hashes); |
+ const HashValueVector& hashes, |
+ const std::string& report_uri); |
// Returns true iff we have any static public key pins for the |host| and |
// iff its set of required pins is the set we expect for Google |
@@ -291,9 +341,14 @@ class NET_EXPORT TransportSecurityState |
static bool IsBuildTimely(); |
// Helper method for actually checking pins. |
- bool CheckPublicKeyPinsImpl(const std::string& host, |
- const HashValueVector& hashes, |
- std::string* failure_log); |
+ bool CheckPublicKeyPinsImpl( |
+ const std::string& host, |
+ const HashValueVector& hashes, |
+ uint16_t port, |
+ const scoped_refptr<X509Certificate>& served_certificate_chain, |
+ const scoped_refptr<X509Certificate>& validated_certificate_chain, |
+ const PublicKeyPinReportStatus report_status, |
+ std::string* failure_log); |
// If a Delegate is present, notify it that the internal state has |
// changed. |
@@ -310,7 +365,8 @@ class NET_EXPORT TransportSecurityState |
const base::Time& last_observed, |
const base::Time& expiry, |
bool include_subdomains, |
- const HashValueVector& hashes); |
+ const HashValueVector& hashes, |
+ const std::string& report_uri); |
// Enable TransportSecurity for |host|. |state| supercedes any previous |
// state for the |host|, including static entries. |
@@ -325,6 +381,8 @@ class NET_EXPORT TransportSecurityState |
Delegate* delegate_; |
+ Reporter* reporter_; |
+ |
// True if static pins should be used. |
bool enable_static_pins_; |