| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/time.h" | 12 #include "base/time.h" |
| 13 #include "chrome/browser/net/cert_logger.pb.h" | 13 #include "chrome/browser/net/cert_logger.pb.h" |
| 14 #include "net/base/load_flags.h" | 14 #include "net/base/load_flags.h" |
| 15 #include "net/base/ssl_info.h" | 15 #include "net/base/ssl_info.h" |
| 16 #include "net/base/upload_data.h" |
| 16 #include "net/base/x509_certificate.h" | 17 #include "net/base/x509_certificate.h" |
| 17 #include "net/url_request/url_request_context.h" | 18 #include "net/url_request/url_request_context.h" |
| 18 | 19 |
| 19 namespace chrome_browser_net { | 20 namespace chrome_browser_net { |
| 20 | 21 |
| 21 // TODO(palmer): Switch to HTTPS when the error handling delegate is more | 22 // TODO(palmer): Switch to HTTPS when the error handling delegate is more |
| 22 // sophisticated. Ultimately we plan to attempt the report on many transports. | 23 // sophisticated. Ultimately we plan to attempt the report on many transports. |
| 23 static const char kFraudulentCertificateUploadEndpoint[] = | 24 static const char kFraudulentCertificateUploadEndpoint[] = |
| 24 "http://clients3.google.com/log_cert_error"; | 25 "http://clients3.google.com/log_cert_error"; |
| 25 | 26 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // domains (when we start supporting that), we will ask for user permission. | 71 // domains (when we start supporting that), we will ask for user permission. |
| 71 if (!net::TransportSecurityState::IsGooglePinnedProperty(hostname, | 72 if (!net::TransportSecurityState::IsGooglePinnedProperty(hostname, |
| 72 sni_available)) { | 73 sni_available)) { |
| 73 return; | 74 return; |
| 74 } | 75 } |
| 75 | 76 |
| 76 std::string report = BuildReport(hostname, ssl_info); | 77 std::string report = BuildReport(hostname, ssl_info); |
| 77 | 78 |
| 78 net::URLRequest* url_request = CreateURLRequest(request_context_); | 79 net::URLRequest* url_request = CreateURLRequest(request_context_); |
| 79 url_request->set_method("POST"); | 80 url_request->set_method("POST"); |
| 80 url_request->AppendBytesToUpload(report.data(), report.size()); | 81 |
| 82 scoped_refptr<net::UploadData> upload_data(new net::UploadData()); |
| 83 upload_data->AppendBytes(report.data(), report.size()); |
| 84 url_request->set_upload(upload_data); |
| 81 | 85 |
| 82 net::HttpRequestHeaders headers; | 86 net::HttpRequestHeaders headers; |
| 83 headers.SetHeader(net::HttpRequestHeaders::kContentType, | 87 headers.SetHeader(net::HttpRequestHeaders::kContentType, |
| 84 "x-application/chrome-fraudulent-cert-report"); | 88 "x-application/chrome-fraudulent-cert-report"); |
| 85 url_request->SetExtraRequestHeaders(headers); | 89 url_request->SetExtraRequestHeaders(headers); |
| 86 | 90 |
| 87 inflight_requests_.insert(url_request); | 91 inflight_requests_.insert(url_request); |
| 88 url_request->Start(); | 92 url_request->Start(); |
| 89 } | 93 } |
| 90 | 94 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 110 LOG(WARNING) << "Certificate upload HTTP status: " | 114 LOG(WARNING) << "Certificate upload HTTP status: " |
| 111 << request->GetResponseCode(); | 115 << request->GetResponseCode(); |
| 112 } | 116 } |
| 113 RequestComplete(request); | 117 RequestComplete(request); |
| 114 } | 118 } |
| 115 | 119 |
| 116 void ChromeFraudulentCertificateReporter::OnReadCompleted( | 120 void ChromeFraudulentCertificateReporter::OnReadCompleted( |
| 117 net::URLRequest* request, int bytes_read) {} | 121 net::URLRequest* request, int bytes_read) {} |
| 118 | 122 |
| 119 } // namespace chrome_browser_net | 123 } // namespace chrome_browser_net |
| 120 | |
| OLD | NEW |