Index: chrome/browser/ssl/chrome_expect_staple_reporter.cc |
diff --git a/chrome/browser/ssl/chrome_expect_staple_reporter.cc b/chrome/browser/ssl/chrome_expect_staple_reporter.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a7b6b832b370cd906c5b6d6b1a5e8387fe6762d7 |
--- /dev/null |
+++ b/chrome/browser/ssl/chrome_expect_staple_reporter.cc |
@@ -0,0 +1,49 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/ssl/chrome_expect_staple_reporter.h" |
+ |
+#include "base/json/json_writer.h" |
+#include "base/strings/stringprintf.h" |
+#include "base/values.h" |
+#include "net/url_request/certificate_report_sender.h" |
+ |
+namespace { |
+ std::string TimeToISO8601(const base::Time& t) { |
+ base::Time::Exploded exploded; |
+ t.UTCExplode(&exploded); |
+ return base::StringPrintf( |
+ "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", exploded.year, exploded.month, |
+ exploded.day_of_month, exploded.hour, exploded.minute, exploded.second, |
+ exploded.millisecond); |
+ } |
+} |
+ |
+ChromeExpectStapleReporter::ChromeExpectStapleReporter( |
+ net::URLRequestContext* request_context) |
+ : report_sender_(new net::CertificateReportSender( |
+ request_context, |
+ net::CertificateReportSender::DO_NOT_SEND_COOKIES)) {} |
+ |
+void ChromeExpectStapleReporter::OnExpectStapleFailed( |
+ const net::HostPortPair& host_port_pair, |
+ const GURL& report_uri, |
+ const net::SSLInfo& ssl_info) { |
+ DCHECK(report_sender_); |
dadrian
2016/06/03 19:05:18
So, a lot of this function is similar to ChromeExp
estark
2016/06/04 00:39:16
Hmmm. If we do things this way, my vote would be f
estark
2016/06/04 00:40:43
Oh, I suppose my alternative vision of the univers
|
+ base::DictionaryValue report; |
+ // TODO: Get this to be the actual verification time |
+ report.SetString("date-time", TimeToISO8601(base::Time::Now())); |
+ report.SetString("hostname", host_port_pair.host()); |
+ report.SetInteger("port", host_port_pair.port()); |
+ |
+ // TODO: Get actual OCSP responses |
+ // TODO: Get certificate chain |
+ std::string serialized_report; |
+ if (!base::JSONWriter::Write(report, &serialized_report)) { |
+ LOG(ERROR) << "Failed to serialize Expect-Staple report"; |
+ return; |
+ } |
+ |
+ report_sender_->Send(report_uri, serialized_report); |
+} |