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

Unified Diff: net/http/transport_security_state.h

Issue 1212613004: Build and send HPKP violation reports (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rsleevi comments Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/transport_security_reporter.cc ('k') | net/http/transport_security_state.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/transport_security_state.h
diff --git a/net/http/transport_security_state.h b/net/http/transport_security_state.h
index 0e9e762bdb4ffbd250aba2ddfd7bf74f39279b2a..8c9782f382eb6968aaf35d1ae7175a9aa948ea39 100644
--- a/net/http/transport_security_state.h
+++ b/net/http/transport_security_state.h
@@ -5,12 +5,13 @@
#ifndef NET_HTTP_TRANSPORT_SECURITY_STATE_H_
#define NET_HTTP_TRANSPORT_SECURITY_STATE_H_
+#include <stdint.h>
+
#include <map>
#include <string>
#include <utility>
#include <vector>
-#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
#include "base/threading/non_thread_safe.h"
#include "base/time/time.h"
@@ -18,6 +19,8 @@
#include "net/cert/x509_cert_types.h"
#include "net/cert/x509_certificate.h"
+class GURL;
+
namespace net {
class SSLInfo;
@@ -45,9 +48,6 @@ class NET_EXPORT TransportSecurityState
virtual ~Delegate() {}
};
- TransportSecurityState();
- ~TransportSecurityState();
-
// A STSState describes the strict transport security state (required
// upgrade to HTTPS).
class NET_EXPORT STSState {
@@ -178,10 +178,62 @@ class NET_EXPORT TransportSecurityState
std::map<std::string, PKPState>::const_iterator end_;
};
+ class NET_EXPORT Reporter {
+ public:
+ // Allows the reporter to override the reporting state in some cases
+ // (for example, if reports should always be sent for certain
+ // hostnames regardless of the HPKP state). 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.
davidben 2015/07/15 23:38:35 It seems Ryan partially asked this, but where are
estark 2015/07/15 23:51:36 Hmm, sorry, maybe it would have been clearer if I
davidben 2015/07/16 00:22:53 Ah, gotcha. Would it work to model that as another
estark 2015/07/16 01:41:13 I was thinking that the ChromeTransportSecurityRep
davidben 2015/07/16 22:39:19 Ah, okay. How would you then know in BuildHPKPRepo
+ virtual bool GetHPKPReportUri(const PKPState& pkp_state,
+ GURL* report_uri) = 0;
+
+ // Builds a serialized HPKP violation report in
+ // |serialized_report|. The information included in the report is:
+ //
+ // - The |hostname| and |port| to which the request was sent that
+ // triggered this report.
+ // - |expiry|, the time at which the HPKP state that triggered this
+ // report will expire.
+ // - |include_subdomains|, indicating whether the includeSubdomains
+ // directive was observed for this pin.
+ // - |effective_hostname|, the hostname that was noted for the
+ // pin. This can be different than |hostname| if, for example,
+ // the pin was for foo.com with includeSubdomains and the request
+ // that triggered the report was example.foo.com.
+ // - |served_certificate_chain| and |validated_certificate_chain|,
+ // the certificate chains as received by the client and as built
+ // during certificate verification.
+ // - The |spki_hashes| to which the |effective_hostname| is pinned.
+ //
+ // 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 X509Certificate* served_certificate_chain,
+ const X509Certificate* validated_certificate_chain,
+ const HashValueVector& spki_hashes,
+ std::string* serialized_report) = 0;
davidben 2015/07/15 23:38:35 Can this not be in TransportSecurityState? There's
estark 2015/07/15 23:51:37 ChromeTransportSecurityReporter will have two repo
+
+ // Sends the given serialized |report| to |report_uri|.
+ virtual void SendHPKPReport(const GURL& report_uri,
+ const std::string& report) = 0;
davidben 2015/07/15 23:38:35 If we could get rid of GetHPKPReportUri or do it d
estark 2015/07/15 23:51:36 Here is what I'm thinking: - TransportSecurityStat
davidben 2015/07/16 00:22:53 Ah, okay, so the CertificateReportSender is less b
+
+ protected:
+ virtual ~Reporter() {}
+ };
+
+ TransportSecurityState();
+ ~TransportSecurityState();
+
// These functions search for static and dynamic STS and PKP states, and
- // invoke the
- // functions of the same name on them. These functions are the primary public
- // interface; direct access to STS and PKP states is best left to tests.
+ // invoke the functions of the same name on them. These functions are the
+ // primary public interface; direct access to STS and PKP states is best
+ // left to tests.
bool ShouldSSLErrorsBeFatal(const std::string& host);
bool ShouldUpgradeToSSL(const std::string& host);
bool CheckPublicKeyPins(const std::string& host,
@@ -197,6 +249,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
@@ -350,6 +404,8 @@ class NET_EXPORT TransportSecurityState
Delegate* delegate_;
+ Reporter* reporter_;
+
// True if static pins should be used.
bool enable_static_pins_;
« no previous file with comments | « net/http/transport_security_reporter.cc ('k') | net/http/transport_security_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698