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

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

Issue 1117173004: Split cert reporter class into report building/serializing and sending (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: BUILD.gn fix Created 5 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ssl/certificate_error_report.h"
6
7 #include <vector>
8
9 #include "base/stl_util.h"
10 #include "base/time/time.h"
11 #include "net/cert/x509_certificate.h"
12 #include "net/ssl/ssl_info.h"
13
14 namespace chrome_browser_ssl {
15
16 CertificateErrorReport::CertificateErrorReport() {
17 }
18
19 CertificateErrorReport::CertificateErrorReport(const std::string& hostname,
20 const net::SSLInfo& ssl_info) {
21 base::Time now = base::Time::Now();
22 cert_report_.set_time_usec(now.ToInternalValue());
eroman 2015/05/12 00:27:51 Is it the case that base::Time's internal value us
estark 2015/05/12 20:42:16 It looks like it actually uses the Windows epoch o
23 cert_report_.set_hostname(hostname);
eroman 2015/05/12 00:27:51 is the assumption that hostname will be ASCII?
estark 2015/05/12 20:42:16 I'm not sure... I think in practice only ASCII wil
24
25 std::vector<std::string> pem_encoded_chain;
26 if (!ssl_info.cert->GetPEMEncodedChain(&pem_encoded_chain))
27 LOG(ERROR) << "Could not get PEM encoded chain.";
eroman 2015/05/12 00:27:51 nit: Maybe I am just paranoid, but anytime I see m
estark 2015/05/12 20:42:16 Done.
28
29 std::string* cert_chain = cert_report_.mutable_cert_chain();
30 for (size_t i = 0; i < pem_encoded_chain.size(); ++i)
31 *cert_chain += pem_encoded_chain[i];
eroman 2015/05/12 00:27:51 would std::string::append() be better than += ? P
estark 2015/05/12 20:42:16 Changed to use std::string::append() but I don't t
32
33 cert_report_.add_pin(ssl_info.pinning_failure_log);
34 }
35
36 CertificateErrorReport::~CertificateErrorReport() {
37 }
38
39 bool CertificateErrorReport::InitializeFromString(
40 const std::string& serialized_report) {
41 return cert_report_.ParseFromString(serialized_report);
42 }
43
44 void CertificateErrorReport::Serialize(std::string* output) const {
45 cert_report_.SerializeToString(output);
eroman 2015/05/12 00:27:51 This can return a failure. Why is it not necessary
estark 2015/05/12 20:42:16 Oh I didn't realize it returned a value. Changed t
46 }
47
48 const std::string& CertificateErrorReport::hostname() const {
49 return cert_report_.hostname();
50 }
51
52 } // namespace chrome_browser_ssl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698