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" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } | 47 } |
48 std::string* cert_chain = request.mutable_cert_chain(); | 48 std::string* cert_chain = request.mutable_cert_chain(); |
49 for (size_t i = 0; i < pem_encoded_chain.size(); ++i) | 49 for (size_t i = 0; i < pem_encoded_chain.size(); ++i) |
50 *cert_chain += pem_encoded_chain[i]; | 50 *cert_chain += pem_encoded_chain[i]; |
51 | 51 |
52 std::string out; | 52 std::string out; |
53 request.SerializeToString(&out); | 53 request.SerializeToString(&out); |
54 return out; | 54 return out; |
55 } | 55 } |
56 | 56 |
57 net::URLRequest* ChromeFraudulentCertificateReporter::CreateURLRequest() { | 57 net::URLRequest* ChromeFraudulentCertificateReporter::CreateURLRequest( |
58 net::URLRequest* request = new net::URLRequest(upload_url_, this); | 58 net::URLRequestContext* context) { |
| 59 net::URLRequest* request = new net::URLRequest(upload_url_, this, context); |
59 request->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES | | 60 request->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES | |
60 net::LOAD_DO_NOT_SAVE_COOKIES); | 61 net::LOAD_DO_NOT_SAVE_COOKIES); |
61 return request; | 62 return request; |
62 } | 63 } |
63 | 64 |
64 void ChromeFraudulentCertificateReporter::SendReport( | 65 void ChromeFraudulentCertificateReporter::SendReport( |
65 const std::string& hostname, | 66 const std::string& hostname, |
66 const net::SSLInfo& ssl_info, | 67 const net::SSLInfo& ssl_info, |
67 bool sni_available) { | 68 bool sni_available) { |
68 // We do silent/automatic reporting ONLY for Google properties. For other | 69 // We do silent/automatic reporting ONLY for Google properties. For other |
69 // domains (when we start supporting that), we will ask for user permission. | 70 // domains (when we start supporting that), we will ask for user permission. |
70 if (!net::TransportSecurityState::IsGooglePinnedProperty(hostname, | 71 if (!net::TransportSecurityState::IsGooglePinnedProperty(hostname, |
71 sni_available)) { | 72 sni_available)) { |
72 return; | 73 return; |
73 } | 74 } |
74 | 75 |
75 std::string report = BuildReport(hostname, ssl_info); | 76 std::string report = BuildReport(hostname, ssl_info); |
76 | 77 |
77 net::URLRequest* url_request = CreateURLRequest(); | 78 net::URLRequest* url_request = CreateURLRequest(request_context_); |
78 url_request->set_context(request_context_); | |
79 url_request->set_method("POST"); | 79 url_request->set_method("POST"); |
80 url_request->AppendBytesToUpload(report.data(), report.size()); | 80 url_request->AppendBytesToUpload(report.data(), report.size()); |
81 | 81 |
82 net::HttpRequestHeaders headers; | 82 net::HttpRequestHeaders headers; |
83 headers.SetHeader(net::HttpRequestHeaders::kContentType, | 83 headers.SetHeader(net::HttpRequestHeaders::kContentType, |
84 "x-application/chrome-fraudulent-cert-report"); | 84 "x-application/chrome-fraudulent-cert-report"); |
85 url_request->SetExtraRequestHeaders(headers); | 85 url_request->SetExtraRequestHeaders(headers); |
86 | 86 |
87 inflight_requests_.insert(url_request); | 87 inflight_requests_.insert(url_request); |
88 url_request->Start(); | 88 url_request->Start(); |
(...skipping 22 matching lines...) Expand all Loading... |
111 << request->GetResponseCode(); | 111 << request->GetResponseCode(); |
112 } | 112 } |
113 RequestComplete(request); | 113 RequestComplete(request); |
114 } | 114 } |
115 | 115 |
116 void ChromeFraudulentCertificateReporter::OnReadCompleted( | 116 void ChromeFraudulentCertificateReporter::OnReadCompleted( |
117 net::URLRequest* request, int bytes_read) {} | 117 net::URLRequest* request, int bytes_read) {} |
118 | 118 |
119 } // namespace chrome_browser_net | 119 } // namespace chrome_browser_net |
120 | 120 |
OLD | NEW |