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

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

Issue 935663004: Add checkbox for reporting invalid TLS/SSL cert chains (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comment typo Created 5 years, 9 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 "base/memory/weak_ptr.h"
13 #include "net/url_request/url_request.h" 14 #include "net/url_request/url_request.h"
14 #include "url/gurl.h" 15 #include "url/gurl.h"
15 16
17 namespace content {
18 class WebContents;
19 }
20
16 namespace net { 21 namespace net {
17 class URLRequestContext; 22 class URLRequestContext;
18 class SSLInfo; 23 class SSLInfo;
19 } 24 }
20 25
21 namespace chrome_browser_net { 26 namespace chrome_browser_net {
22 27
23 class CertLoggerRequest; 28 class CertLoggerRequest;
24 29
30 extern const char kExtendedReportingUploadUrl[];
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 // Create a certificate error reporter that will send certificate 46 // Create a certificate error reporter that will send certificate
40 // error reports to |upload_url|, using |request_context| as the 47 // error reports to |upload_url|, using |request_context| as the
41 // context for the reports. 48 // context for the reports.
42 CertificateErrorReporter(net::URLRequestContext* request_context, 49 CertificateErrorReporter(net::URLRequestContext* request_context,
43 const GURL& upload_url); 50 const GURL& upload_url);
44 51
45 ~CertificateErrorReporter() override; 52 ~CertificateErrorReporter() override;
46 53
47 // Construct, serialize, and send a certificate reporter to the report 54 // Construct, serialize, and send a certificate report to the report
48 // collection server containing the |ssl_info| associated with a 55 // collection server containing the |ssl_info| associated with a
49 // connection to |hostname|. 56 // connection to |hostname|.
50 virtual void SendReport(ReportType type, 57 virtual void SendReport(ReportType type,
51 const std::string& hostname, 58 const std::string& hostname,
52 const net::SSLInfo& ssl_info); 59 const net::SSLInfo& ssl_info);
53 60
54 // net::URLRequest::Delegate 61 // net::URLRequest::Delegate
55 void OnResponseStarted(net::URLRequest* request) override; 62 void OnResponseStarted(net::URLRequest* request) override;
56 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; 63 void OnReadCompleted(net::URLRequest* request, int bytes_read) override;
57 64
65 base::WeakPtr<CertificateErrorReporter> GetWeakPtr();
66
58 private: 67 private:
59 // Create a URLRequest with which to send a certificate report to the 68 // Create a URLRequest with which to send a certificate report to the
60 // server. 69 // server.
61 virtual scoped_ptr<net::URLRequest> CreateURLRequest( 70 virtual scoped_ptr<net::URLRequest> CreateURLRequest(
62 net::URLRequestContext* context); 71 net::URLRequestContext* context);
63 72
64 // Serialize and send a CertLoggerRequest protobuf to the report 73 // Serialize and send a CertLoggerRequest protobuf to the report
65 // collection server. 74 // collection server.
66 void SendCertLoggerRequest(const CertLoggerRequest& request); 75 void SendCertLoggerRequest(const CertLoggerRequest& request);
67 76
68 // Populate the CertLoggerRequest for a report. 77 // Populate the CertLoggerRequest for a report.
69 static void BuildReport(const std::string& hostname, 78 static void BuildReport(const std::string& hostname,
70 const net::SSLInfo& ssl_info, 79 const net::SSLInfo& ssl_info,
71 CertLoggerRequest* out_request); 80 CertLoggerRequest* out_request);
72 81
73 // Performs post-report cleanup. 82 // Performs post-report cleanup.
74 void RequestComplete(net::URLRequest* request); 83 void RequestComplete(net::URLRequest* request);
75 84
76 net::URLRequestContext* const request_context_; 85 net::URLRequestContext* const request_context_;
77 const GURL upload_url_; 86 const GURL upload_url_;
78 87
79 // Owns the contained requests. 88 // Owns the contained requests.
80 std::set<net::URLRequest*> inflight_requests_; 89 std::set<net::URLRequest*> inflight_requests_;
81 90
91 base::WeakPtrFactory<CertificateErrorReporter> weak_ptr_factory_;
92
82 DISALLOW_COPY_AND_ASSIGN(CertificateErrorReporter); 93 DISALLOW_COPY_AND_ASSIGN(CertificateErrorReporter);
83 }; 94 };
84 95
85 } // namespace chrome_browser_net 96 } // namespace chrome_browser_net
86 97
87 #endif // CHROME_BROWSER_NET_CERTIFICATE_ERROR_REPORTER_H_ 98 #endif // CHROME_BROWSER_NET_CERTIFICATE_ERROR_REPORTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698