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

Side by Side Diff: chrome/browser/net/certificate_error_reporter.h

Issue 1083493003: Encrypt certificate reports before uploading to HTTP URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make nonce/key length static functions on Aead Created 5 years, 8 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 CHROME_BROWSER_NET_CERTIFICATE_ERROR_REPORTER_H_ 5 #ifndef CHROME_BROWSER_NET_CERTIFICATE_ERROR_REPORTER_H_
6 #define CHROME_BROWSER_NET_CERTIFICATE_ERROR_REPORTER_H_ 6 #define CHROME_BROWSER_NET_CERTIFICATE_ERROR_REPORTER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "net/url_request/url_request.h" 13 #include "net/url_request/url_request.h"
14 #include "url/gurl.h" 14 #include "url/gurl.h"
15 15
16 namespace net { 16 namespace net {
17 class URLRequestContext; 17 class URLRequestContext;
18 class SSLInfo; 18 class SSLInfo;
19 } 19 }
20 20
21 namespace chrome_browser_net { 21 namespace chrome_browser_net {
22 22
23 class CertLoggerRequest; 23 class CertLoggerRequest;
24 class EncryptedCertLoggerRequest;
25
26 // Used by tests.
27 bool DecryptCertificateErrorReport(
agl 2015/04/21 20:28:25 Could this be a static method on CertificateErrorR
estark 2015/04/22 03:55:30 Done. (Sorry, missed that in your first review.)
28 const uint8 server_private_key[32],
29 const EncryptedCertLoggerRequest& encrypted_report,
30 CertLoggerRequest* decrypted_report);
24 31
25 // Provides functionality for sending reports about invalid SSL 32 // Provides functionality for sending reports about invalid SSL
26 // certificate chains to a report collection server. 33 // certificate chains to a report collection server.
27 class CertificateErrorReporter : public net::URLRequest::Delegate { 34 class CertificateErrorReporter : public net::URLRequest::Delegate {
28 public: 35 public:
29 // These represent the types of reports that can be sent. 36 // These represent the types of reports that can be sent.
30 enum ReportType { 37 enum ReportType {
31 // A report of a certificate chain that failed a certificate pinning 38 // A report of a certificate chain that failed a certificate pinning
32 // check. 39 // check.
33 REPORT_TYPE_PINNING_VIOLATION, 40 REPORT_TYPE_PINNING_VIOLATION,
34 // A report for an invalid certificate chain that is being sent for 41 // A report for an invalid certificate chain that is being sent for
35 // a user who has opted-in to the extended reporting program. 42 // a user who has opted-in to the extended reporting program.
36 REPORT_TYPE_EXTENDED_REPORTING 43 REPORT_TYPE_EXTENDED_REPORTING
37 }; 44 };
38 45
39 // Represents whether or not to send cookies along with reports sent 46 // Represents whether or not to send cookies along with reports sent
40 // to the server. 47 // to the server.
41 enum CookiesPreference { SEND_COOKIES, DO_NOT_SEND_COOKIES }; 48 enum CookiesPreference { SEND_COOKIES, DO_NOT_SEND_COOKIES };
42 49
43 // Create a certificate error reporter that will send certificate 50 // Create a certificate error reporter that will send certificate
44 // error reports to |upload_url|, using |request_context| as the 51 // error reports to |upload_url|, using |request_context| as the
45 // context for the reports. |cookies_preference| controls whether 52 // context for the reports. |cookies_preference| controls whether
46 // cookies will be sent along with the reports. 53 // cookies will be sent along with the reports.
47 CertificateErrorReporter(net::URLRequestContext* request_context, 54 CertificateErrorReporter(net::URLRequestContext* request_context,
48 const GURL& upload_url, 55 const GURL& upload_url,
49 CookiesPreference cookies_preference); 56 CookiesPreference cookies_preference);
50 57
58 // Allows tests to use a server public key with known private key.
59 CertificateErrorReporter(net::URLRequestContext* request_context,
60 const GURL& upload_url,
61 CookiesPreference cookies_preference,
62 const uint8 server_public_key[32],
63 const uint32 server_public_key_version);
64
51 ~CertificateErrorReporter() override; 65 ~CertificateErrorReporter() override;
52 66
53 // Construct, serialize, and send a certificate report to the report 67 // Construct, serialize, and send a certificate report to the report
54 // collection server containing the |ssl_info| associated with a 68 // collection server containing the |ssl_info| associated with a
55 // connection to |hostname|. 69 // connection to |hostname|.
56 // 70 //
57 // SendReport actually sends the report over the network; callers are 71 // SendReport actually sends the report over the network; callers are
58 // responsible for enforcing any preconditions (such as obtaining user 72 // responsible for enforcing any preconditions (such as obtaining user
59 // opt-in, only sending reports for certain hostnames, checking for 73 // opt-in, only sending reports for certain hostnames, checking for
60 // incognito mode, etc.). 74 // incognito mode, etc.).
61 virtual void SendReport(ReportType type, 75 virtual void SendReport(ReportType type,
62 const std::string& hostname, 76 const std::string& hostname,
63 const net::SSLInfo& ssl_info); 77 const net::SSLInfo& ssl_info);
64 78
65 // net::URLRequest::Delegate 79 // net::URLRequest::Delegate
66 void OnResponseStarted(net::URLRequest* request) override; 80 void OnResponseStarted(net::URLRequest* request) override;
67 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; 81 void OnReadCompleted(net::URLRequest* request, int bytes_read) override;
68 82
83 // On some platforms (but not all), CertificateErrorReporter can use
84 // an HTTP endpoint to send encrypted extended reporting reports. On
85 // unsupported platforms, callers must send extended reporting reports
86 // over SSL.
87 static bool IsHttpUploadUrlSupported();
estark 2015/04/18 05:24:42 This seems weird to me but I'm not sure what else
88
69 private: 89 private:
70 // Create a URLRequest with which to send a certificate report to the 90 // Create a URLRequest with which to send a certificate report to the
71 // server. 91 // server.
72 virtual scoped_ptr<net::URLRequest> CreateURLRequest( 92 virtual scoped_ptr<net::URLRequest> CreateURLRequest(
73 net::URLRequestContext* context); 93 net::URLRequestContext* context);
74 94
75 // Serialize and send a CertLoggerRequest protobuf to the report 95 // Serialize and send a CertLoggerRequest protobuf to the report
76 // collection server. 96 // collection server.
77 void SendCertLoggerRequest(const CertLoggerRequest& request); 97 void SendCertLoggerRequest(const CertLoggerRequest& request);
78 98
99 void SendSerializedRequest(const std::string& serialized_request);
100
79 // Populate the CertLoggerRequest for a report. 101 // Populate the CertLoggerRequest for a report.
80 static void BuildReport(const std::string& hostname, 102 static void BuildReport(const std::string& hostname,
81 const net::SSLInfo& ssl_info, 103 const net::SSLInfo& ssl_info,
82 CertLoggerRequest* out_request); 104 CertLoggerRequest* out_request);
83 105
84 // Performs post-report cleanup. 106 // Performs post-report cleanup.
85 void RequestComplete(net::URLRequest* request); 107 void RequestComplete(net::URLRequest* request);
86 108
87 net::URLRequestContext* const request_context_; 109 net::URLRequestContext* const request_context_;
88 const GURL upload_url_; 110 const GURL upload_url_;
89 111
90 // Owns the contained requests. 112 // Owns the contained requests.
91 std::set<net::URLRequest*> inflight_requests_; 113 std::set<net::URLRequest*> inflight_requests_;
92 114
93 CookiesPreference cookies_preference_; 115 CookiesPreference cookies_preference_;
94 116
117 const uint8* server_public_key_;
118 const uint32 server_public_key_version_;
119
95 DISALLOW_COPY_AND_ASSIGN(CertificateErrorReporter); 120 DISALLOW_COPY_AND_ASSIGN(CertificateErrorReporter);
96 }; 121 };
97 122
98 } // namespace chrome_browser_net 123 } // namespace chrome_browser_net
99 124
100 #endif // CHROME_BROWSER_NET_CERTIFICATE_ERROR_REPORTER_H_ 125 #endif // CHROME_BROWSER_NET_CERTIFICATE_ERROR_REPORTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698