OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ssl/chrome_expect_staple_reporter.h" | |
6 | |
7 #include "base/json/json_writer.h" | |
8 #include "base/strings/stringprintf.h" | |
9 #include "base/values.h" | |
10 #include "net/url_request/certificate_report_sender.h" | |
11 | |
12 namespace { | |
13 std::string TimeToISO8601(const base::Time& t) { | |
14 base::Time::Exploded exploded; | |
15 t.UTCExplode(&exploded); | |
16 return base::StringPrintf( | |
17 "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", exploded.year, exploded.month, | |
18 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second, | |
19 exploded.millisecond); | |
20 } | |
21 } | |
22 | |
23 ChromeExpectStapleReporter::ChromeExpectStapleReporter( | |
24 net::URLRequestContext* request_context) | |
25 : report_sender_(new net::CertificateReportSender( | |
26 request_context, | |
27 net::CertificateReportSender::DO_NOT_SEND_COOKIES)) {} | |
28 | |
29 void ChromeExpectStapleReporter::OnExpectStapleFailed( | |
30 const net::HostPortPair& host_port_pair, | |
31 const GURL& report_uri, | |
32 const net::SSLInfo& ssl_info) { | |
33 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
| |
34 base::DictionaryValue report; | |
35 // TODO: Get this to be the actual verification time | |
36 report.SetString("date-time", TimeToISO8601(base::Time::Now())); | |
37 report.SetString("hostname", host_port_pair.host()); | |
38 report.SetInteger("port", host_port_pair.port()); | |
39 | |
40 // TODO: Get actual OCSP responses | |
41 // TODO: Get certificate chain | |
42 std::string serialized_report; | |
43 if (!base::JSONWriter::Write(report, &serialized_report)) { | |
44 LOG(ERROR) << "Failed to serialize Expect-Staple report"; | |
45 return; | |
46 } | |
47 | |
48 report_sender_->Send(report_uri, serialized_report); | |
49 } | |
OLD | NEW |