Chromium Code Reviews| Index: chrome/browser/ssl/certificate_error_report.cc |
| diff --git a/chrome/browser/ssl/certificate_error_report.cc b/chrome/browser/ssl/certificate_error_report.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bd0b6bd5c91ab624c0a0c0fb5512f96835758f6b |
| --- /dev/null |
| +++ b/chrome/browser/ssl/certificate_error_report.cc |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2015 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/certificate_error_report.h" |
| + |
| +#include <vector> |
| + |
| +#include "base/stl_util.h" |
| +#include "base/time/time.h" |
| +#include "net/cert/x509_certificate.h" |
| +#include "net/ssl/ssl_info.h" |
| + |
| +namespace chrome_browser_ssl { |
| + |
| +CertificateErrorReport::CertificateErrorReport() { |
| +} |
| + |
| +CertificateErrorReport::CertificateErrorReport(const std::string& hostname, |
| + const net::SSLInfo& ssl_info) { |
| + base::Time now = base::Time::Now(); |
| + 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
|
| + 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
|
| + |
| + std::vector<std::string> pem_encoded_chain; |
| + if (!ssl_info.cert->GetPEMEncodedChain(&pem_encoded_chain)) |
| + 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.
|
| + |
| + std::string* cert_chain = cert_report_.mutable_cert_chain(); |
| + for (size_t i = 0; i < pem_encoded_chain.size(); ++i) |
| + *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
|
| + |
| + cert_report_.add_pin(ssl_info.pinning_failure_log); |
| +} |
| + |
| +CertificateErrorReport::~CertificateErrorReport() { |
| +} |
| + |
| +bool CertificateErrorReport::InitializeFromString( |
| + const std::string& serialized_report) { |
| + return cert_report_.ParseFromString(serialized_report); |
| +} |
| + |
| +void CertificateErrorReport::Serialize(std::string* output) const { |
| + 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
|
| +} |
| + |
| +const std::string& CertificateErrorReport::hostname() const { |
| + return cert_report_.hostname(); |
| +} |
| + |
| +} // namespace chrome_browser_ssl |