| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/net/chrome_fraudulent_certificate_reporter.h" | 5 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 const std::string& hostname, | 58 const std::string& hostname, |
| 59 const net::SSLInfo& ssl_info) { | 59 const net::SSLInfo& ssl_info) { |
| 60 CertLoggerRequest request; | 60 CertLoggerRequest request; |
| 61 base::Time now = base::Time::Now(); | 61 base::Time now = base::Time::Now(); |
| 62 request.set_time_usec(now.ToInternalValue()); | 62 request.set_time_usec(now.ToInternalValue()); |
| 63 request.set_hostname(hostname); | 63 request.set_hostname(hostname); |
| 64 | 64 |
| 65 std::string der_encoded, pem_encoded; | 65 std::string der_encoded, pem_encoded; |
| 66 | 66 |
| 67 net::X509Certificate* certificate = ssl_info.cert; | 67 net::X509Certificate* certificate = ssl_info.cert; |
| 68 if (!certificate->GetDEREncoded(&der_encoded) || | 68 if (!net::X509Certificate::GetDEREncoded(certificate->os_cert_handle(), |
| 69 &der_encoded) || |
| 69 !DerToPem(der_encoded, &pem_encoded)) { | 70 !DerToPem(der_encoded, &pem_encoded)) { |
| 70 LOG(ERROR) << "Could not PEM encode DER certificate"; | 71 LOG(ERROR) << "Could not PEM encode DER certificate"; |
| 71 } | 72 } |
| 72 | 73 |
| 73 std::string* cert_chain = request.mutable_cert_chain(); | 74 std::string* cert_chain = request.mutable_cert_chain(); |
| 74 *cert_chain += pem_encoded; | 75 *cert_chain += pem_encoded; |
| 75 | 76 |
| 76 const net::X509Certificate::OSCertHandles& intermediates = | 77 const net::X509Certificate::OSCertHandles& intermediates = |
| 77 certificate->GetIntermediateCertificates(); | 78 certificate->GetIntermediateCertificates(); |
| 78 | 79 for (size_t i = 0; i < intermediates.size(); ++i) { |
| 79 for (net::X509Certificate::OSCertHandles::const_iterator | 80 if (!net::X509Certificate::GetDEREncoded(intermediates[i], |
| 80 i = intermediates.begin(); i != intermediates.end(); ++i) { | 81 &der_encoded) || |
| 81 scoped_refptr<net::X509Certificate> cert = | |
| 82 net::X509Certificate::CreateFromHandle(*i, intermediates); | |
| 83 | |
| 84 if (!cert->GetDEREncoded(&der_encoded) || | |
| 85 !DerToPem(der_encoded, &pem_encoded)) { | 82 !DerToPem(der_encoded, &pem_encoded)) { |
| 86 LOG(ERROR) << "Could not PEM encode DER certificate"; | 83 LOG(ERROR) << "Could not PEM encode DER certificate"; |
| 87 continue; | 84 continue; |
| 88 } | 85 } |
| 89 | 86 |
| 90 *cert_chain += pem_encoded; | 87 *cert_chain += pem_encoded; |
| 91 } | 88 } |
| 92 | 89 |
| 93 std::string out; | 90 std::string out; |
| 94 request.SerializeToString(&out); | 91 request.SerializeToString(&out); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 << request->GetResponseCode(); | 146 << request->GetResponseCode(); |
| 150 } | 147 } |
| 151 RequestComplete(request); | 148 RequestComplete(request); |
| 152 } | 149 } |
| 153 | 150 |
| 154 void ChromeFraudulentCertificateReporter::OnReadCompleted( | 151 void ChromeFraudulentCertificateReporter::OnReadCompleted( |
| 155 net::URLRequest* request, int bytes_read) {} | 152 net::URLRequest* request, int bytes_read) {} |
| 156 | 153 |
| 157 } // namespace chrome_browser_net | 154 } // namespace chrome_browser_net |
| 158 | 155 |
| OLD | NEW |