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

Side by Side Diff: chrome/browser/ssl/chrome_expect_ct_reporter.cc

Issue 1863663002: Use Finch flag instead of command line for Expect CT reporting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "chrome/browser/ssl/chrome_expect_ct_reporter.h" 5 #include "chrome/browser/ssl/chrome_expect_ct_reporter.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/feature_list.h"
11 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
12 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_features.h"
16 #include "net/url_request/certificate_report_sender.h" 17 #include "net/url_request/certificate_report_sender.h"
17 18
18 namespace { 19 namespace {
19 20
20 std::string TimeToISO8601(const base::Time& t) { 21 std::string TimeToISO8601(const base::Time& t) {
21 base::Time::Exploded exploded; 22 base::Time::Exploded exploded;
22 t.UTCExplode(&exploded); 23 t.UTCExplode(&exploded);
23 return base::StringPrintf( 24 return base::StringPrintf(
24 "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", exploded.year, exploded.month, 25 "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", exploded.year, exploded.month,
25 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second, 26 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 111
111 ChromeExpectCTReporter::~ChromeExpectCTReporter() {} 112 ChromeExpectCTReporter::~ChromeExpectCTReporter() {}
112 113
113 void ChromeExpectCTReporter::OnExpectCTFailed( 114 void ChromeExpectCTReporter::OnExpectCTFailed(
114 const net::HostPortPair& host_port_pair, 115 const net::HostPortPair& host_port_pair,
115 const GURL& report_uri, 116 const GURL& report_uri,
116 const net::SSLInfo& ssl_info) { 117 const net::SSLInfo& ssl_info) {
117 if (report_uri.is_empty()) 118 if (report_uri.is_empty())
118 return; 119 return;
119 120
120 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 121 if (!base::FeatureList::IsEnabled(features::kExpectCTReporting))
meacer 2016/04/05 18:08:40 This looks new, back in the days when I was young
estark 2016/04/05 18:10:39 Yeah, I think it is new, and it's soooo nice!
121 switches::kEnableExpectCTReporting)) {
122 return; 122 return;
123 }
124 123
125 // TODO(estark): De-duplicate reports so that the same report isn't 124 // TODO(estark): De-duplicate reports so that the same report isn't
126 // sent too often in some period of time. 125 // sent too often in some period of time.
127 126
128 base::DictionaryValue report; 127 base::DictionaryValue report;
129 report.SetString("hostname", host_port_pair.host()); 128 report.SetString("hostname", host_port_pair.host());
130 report.SetInteger("port", host_port_pair.port()); 129 report.SetInteger("port", host_port_pair.port());
131 report.SetString("date-time", TimeToISO8601(base::Time::Now())); 130 report.SetString("date-time", TimeToISO8601(base::Time::Now()));
132 report.Set("served-certificate-chain", 131 report.Set("served-certificate-chain",
133 GetPEMEncodedChainAsList(ssl_info.unverified_cert.get())); 132 GetPEMEncodedChainAsList(ssl_info.unverified_cert.get()));
(...skipping 25 matching lines...) Expand all
159 report.Set("valid-scts", std::move(valid_scts)); 158 report.Set("valid-scts", std::move(valid_scts));
160 159
161 std::string serialized_report; 160 std::string serialized_report;
162 if (!base::JSONWriter::Write(report, &serialized_report)) { 161 if (!base::JSONWriter::Write(report, &serialized_report)) {
163 LOG(ERROR) << "Failed to serialize Expect CT report"; 162 LOG(ERROR) << "Failed to serialize Expect CT report";
164 return; 163 return;
165 } 164 }
166 165
167 report_sender_->Send(report_uri, serialized_report); 166 report_sender_->Send(report_uri, serialized_report);
168 } 167 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/chrome_expect_ct_reporter.h ('k') | chrome/browser/ssl/chrome_expect_ct_reporter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698