| OLD | NEW |
| 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 COMPONENTS_CERTIFICATE_REPORTING_CERTIFICATE_ERROR_REPORTER_H_ | 5 #ifndef COMPONENTS_CERTIFICATE_REPORTING_CERTIFICATE_ERROR_REPORTER_H_ |
| 6 #define COMPONENTS_CERTIFICATE_REPORTING_CERTIFICATE_ERROR_REPORTER_H_ | 6 #define COMPONENTS_CERTIFICATE_REPORTING_CERTIFICATE_ERROR_REPORTER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "net/url_request/certificate_report_sender.h" | 15 #include "net/url_request/report_sender.h" |
| 16 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 17 | 17 |
| 18 namespace net { | 18 namespace net { |
| 19 class URLRequestContext; | 19 class URLRequestContext; |
| 20 class SSLInfo; | 20 class SSLInfo; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace certificate_reporting { | 23 namespace certificate_reporting { |
| 24 | 24 |
| 25 class EncryptedCertLoggerRequest; | 25 class EncryptedCertLoggerRequest; |
| 26 | 26 |
| 27 // Provides functionality for sending reports about invalid SSL | 27 // Provides functionality for sending reports about invalid SSL |
| 28 // certificate chains to a report collection server. | 28 // certificate chains to a report collection server. |
| 29 class ErrorReporter { | 29 class ErrorReporter { |
| 30 public: | 30 public: |
| 31 // Creates a certificate error reporter that will send certificate | 31 // Creates a certificate error reporter that will send certificate |
| 32 // error reports to |upload_url|, using |request_context| as the | 32 // error reports to |upload_url|, using |request_context| as the |
| 33 // context for the reports. |cookies_preference| controls whether | 33 // context for the reports. |cookies_preference| controls whether |
| 34 // cookies will be sent along with the reports. | 34 // cookies will be sent along with the reports. |
| 35 ErrorReporter( | 35 ErrorReporter(net::URLRequestContext* request_context, |
| 36 net::URLRequestContext* request_context, | 36 const GURL& upload_url, |
| 37 const GURL& upload_url, | 37 net::ReportSender::CookiesPreference cookies_preference); |
| 38 net::CertificateReportSender::CookiesPreference cookies_preference); | |
| 39 | 38 |
| 40 // Allows tests to use a server public key with known private key and | 39 // Allows tests to use a server public key with known private key and |
| 41 // a mock CertificateReportSender. |server_public_key| must outlive | 40 // a mock ReportSender. |server_public_key| must outlive |
| 42 // the ErrorReporter. | 41 // the ErrorReporter. |
| 43 ErrorReporter( | 42 ErrorReporter(const GURL& upload_url, |
| 44 const GURL& upload_url, | 43 const uint8_t server_public_key[/* 32 */], |
| 45 const uint8_t server_public_key[/* 32 */], | 44 const uint32_t server_public_key_version, |
| 46 const uint32_t server_public_key_version, | 45 std::unique_ptr<net::ReportSender> certificate_report_sender); |
| 47 std::unique_ptr<net::CertificateReportSender> certificate_report_sender); | |
| 48 | 46 |
| 49 virtual ~ErrorReporter(); | 47 virtual ~ErrorReporter(); |
| 50 | 48 |
| 51 // Sends a certificate report to the report collection server. The | 49 // Sends a certificate report to the report collection server. The |
| 52 // |serialized_report| is expected to be a serialized protobuf | 50 // |serialized_report| is expected to be a serialized protobuf |
| 53 // containing information about the hostname, certificate chain, and | 51 // containing information about the hostname, certificate chain, and |
| 54 // certificate errors encountered when validating the chain. | 52 // certificate errors encountered when validating the chain. |
| 55 // | 53 // |
| 56 // |SendReport| actually sends the report over the network; callers are | 54 // |SendReport| actually sends the report over the network; callers are |
| 57 // responsible for enforcing any preconditions (such as obtaining user | 55 // responsible for enforcing any preconditions (such as obtaining user |
| (...skipping 10 matching lines...) Expand all Loading... |
| 68 // Whether sending reports over HTTP is supported. | 66 // Whether sending reports over HTTP is supported. |
| 69 static bool IsHttpUploadUrlSupported(); | 67 static bool IsHttpUploadUrlSupported(); |
| 70 | 68 |
| 71 // Used by tests. | 69 // Used by tests. |
| 72 static bool DecryptErrorReport( | 70 static bool DecryptErrorReport( |
| 73 const uint8_t server_private_key[32], | 71 const uint8_t server_private_key[32], |
| 74 const EncryptedCertLoggerRequest& encrypted_report, | 72 const EncryptedCertLoggerRequest& encrypted_report, |
| 75 std::string* decrypted_serialized_report); | 73 std::string* decrypted_serialized_report); |
| 76 | 74 |
| 77 private: | 75 private: |
| 78 std::unique_ptr<net::CertificateReportSender> certificate_report_sender_; | 76 std::unique_ptr<net::ReportSender> certificate_report_sender_; |
| 79 | 77 |
| 80 const GURL upload_url_; | 78 const GURL upload_url_; |
| 81 | 79 |
| 82 const uint8_t* server_public_key_; | 80 const uint8_t* server_public_key_; |
| 83 const uint32_t server_public_key_version_; | 81 const uint32_t server_public_key_version_; |
| 84 | 82 |
| 85 DISALLOW_COPY_AND_ASSIGN(ErrorReporter); | 83 DISALLOW_COPY_AND_ASSIGN(ErrorReporter); |
| 86 }; | 84 }; |
| 87 | 85 |
| 88 } // namespace certificate_reporting | 86 } // namespace certificate_reporting |
| 89 | 87 |
| 90 #endif // COMPONENTS_CERTIFICATE_REPORTING_CERTIFICATE_ERROR_REPORTER_H_ | 88 #endif // COMPONENTS_CERTIFICATE_REPORTING_CERTIFICATE_ERROR_REPORTER_H_ |
| OLD | NEW |