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

Side by Side Diff: content/child/web_url_loader_impl.cc

Issue 1772603002: Addition of Certificate Transparency details to Security panel of DevTools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed some unnecessary includes and fixed order in net.gypi Created 4 years, 8 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/child/web_url_loader_impl.h" 5 #include "content/child/web_url_loader_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
19 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
20 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
21 #include "base/time/time.h" 22 #include "base/time/time.h"
22 #include "build/build_config.h" 23 #include "build/build_config.h"
23 #include "components/mime_util/mime_util.h" 24 #include "components/mime_util/mime_util.h"
24 #include "components/scheduler/child/web_task_runner_impl.h" 25 #include "components/scheduler/child/web_task_runner_impl.h"
25 #include "content/child/child_thread_impl.h" 26 #include "content/child/child_thread_impl.h"
26 #include "content/child/ftp_directory_listing_response_delegate.h" 27 #include "content/child/ftp_directory_listing_response_delegate.h"
27 #include "content/child/request_extra_data.h" 28 #include "content/child/request_extra_data.h"
28 #include "content/child/request_info.h" 29 #include "content/child/request_info.h"
29 #include "content/child/resource_dispatcher.h" 30 #include "content/child/resource_dispatcher.h"
30 #include "content/child/shared_memory_data_consumer_handle.h" 31 #include "content/child/shared_memory_data_consumer_handle.h"
31 #include "content/child/sync_load_response.h" 32 #include "content/child/sync_load_response.h"
32 #include "content/child/web_url_request_util.h" 33 #include "content/child/web_url_request_util.h"
33 #include "content/child/weburlresponse_extradata_impl.h" 34 #include "content/child/weburlresponse_extradata_impl.h"
34 #include "content/common/resource_messages.h" 35 #include "content/common/resource_messages.h"
35 #include "content/common/resource_request_body.h" 36 #include "content/common/resource_request_body.h"
36 #include "content/common/service_worker/service_worker_types.h" 37 #include "content/common/service_worker/service_worker_types.h"
37 #include "content/common/ssl_status_serialization.h" 38 #include "content/common/ssl_status_serialization.h"
38 #include "content/public/child/fixed_received_data.h" 39 #include "content/public/child/fixed_received_data.h"
39 #include "content/public/child/request_peer.h" 40 #include "content/public/child/request_peer.h"
40 #include "content/public/common/browser_side_navigation_policy.h" 41 #include "content/public/common/browser_side_navigation_policy.h"
41 #include "content/public/common/signed_certificate_timestamp_id_and_status.h"
42 #include "content/public/common/ssl_status.h" 42 #include "content/public/common/ssl_status.h"
43 #include "net/base/data_url.h" 43 #include "net/base/data_url.h"
44 #include "net/base/filename_util.h" 44 #include "net/base/filename_util.h"
45 #include "net/base/net_errors.h" 45 #include "net/base/net_errors.h"
46 #include "net/cert/cert_status_flags.h" 46 #include "net/cert/cert_status_flags.h"
47 #include "net/cert/sct_status_flags.h" 47 #include "net/cert/ct_sct_to_string.h"
48 #include "net/http/http_response_headers.h" 48 #include "net/http/http_response_headers.h"
49 #include "net/http/http_util.h" 49 #include "net/http/http_util.h"
50 #include "net/ssl/ssl_cipher_suite_names.h" 50 #include "net/ssl/ssl_cipher_suite_names.h"
51 #include "net/ssl/ssl_connection_status_flags.h" 51 #include "net/ssl/ssl_connection_status_flags.h"
52 #include "net/url_request/url_request_data_job.h" 52 #include "net/url_request/url_request_data_job.h"
53 #include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h" 53 #include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h"
54 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 54 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
55 #include "third_party/WebKit/public/platform/WebTraceLocation.h" 55 #include "third_party/WebKit/public/platform/WebTraceLocation.h"
56 #include "third_party/WebKit/public/platform/WebURL.h" 56 #include "third_party/WebKit/public/platform/WebURL.h"
57 #include "third_party/WebKit/public/platform/WebURLError.h" 57 #include "third_party/WebKit/public/platform/WebURLError.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 info->mime_type.swap(mime_type); 180 info->mime_type.swap(mime_type);
181 info->charset.swap(charset); 181 info->charset.swap(charset);
182 info->security_info.clear(); 182 info->security_info.clear();
183 info->content_length = data->length(); 183 info->content_length = data->length();
184 info->encoded_data_length = 0; 184 info->encoded_data_length = 0;
185 185
186 return net::OK; 186 return net::OK;
187 } 187 }
188 188
189 void SetSecurityStyleAndDetails(const GURL& url, 189 void SetSecurityStyleAndDetails(const GURL& url,
190 const std::string& security_info, 190 const ResourceResponseInfo& info,
191 WebURLResponse* response, 191 WebURLResponse* response,
192 bool report_security_info) { 192 bool report_security_info) {
193 if (!report_security_info) { 193 if (!report_security_info) {
194 response->setSecurityStyle(WebURLResponse::SecurityStyleUnknown); 194 response->setSecurityStyle(WebURLResponse::SecurityStyleUnknown);
195 return; 195 return;
196 } 196 }
197 if (!url.SchemeIsCryptographic()) { 197 if (!url.SchemeIsCryptographic()) {
198 response->setSecurityStyle(WebURLResponse::SecurityStyleUnauthenticated); 198 response->setSecurityStyle(WebURLResponse::SecurityStyleUnauthenticated);
199 return; 199 return;
200 } 200 }
201 201
202 // There are cases where an HTTPS request can come in without security 202 // There are cases where an HTTPS request can come in without security
203 // info attached (such as a redirect response). 203 // info attached (such as a redirect response).
204 const std::string& security_info = info.security_info;
204 if (security_info.empty()) { 205 if (security_info.empty()) {
205 response->setSecurityStyle(WebURLResponse::SecurityStyleUnknown); 206 response->setSecurityStyle(WebURLResponse::SecurityStyleUnknown);
206 return; 207 return;
207 } 208 }
208 209
209 SSLStatus ssl_status; 210 SSLStatus ssl_status;
210 if (!DeserializeSecurityInfo(security_info, &ssl_status)) { 211 if (!DeserializeSecurityInfo(security_info, &ssl_status)) {
211 response->setSecurityStyle(WebURLResponse::SecurityStyleUnknown); 212 response->setSecurityStyle(WebURLResponse::SecurityStyleUnknown);
212 DLOG(ERROR) 213 DLOG(ERROR)
213 << "DeserializeSecurityInfo() failed for an authenticated request."; 214 << "DeserializeSecurityInfo() failed for an authenticated request.";
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 case SECURITY_STYLE_WARNING: 248 case SECURITY_STYLE_WARNING:
248 securityStyle = WebURLResponse::SecurityStyleWarning; 249 securityStyle = WebURLResponse::SecurityStyleWarning;
249 break; 250 break;
250 case SECURITY_STYLE_AUTHENTICATED: 251 case SECURITY_STYLE_AUTHENTICATED:
251 securityStyle = WebURLResponse::SecurityStyleAuthenticated; 252 securityStyle = WebURLResponse::SecurityStyleAuthenticated;
252 break; 253 break;
253 } 254 }
254 255
255 response->setSecurityStyle(securityStyle); 256 response->setSecurityStyle(securityStyle);
256 257
257 SignedCertificateTimestampIDStatusList sct_list = 258 size_t num_unknown_scts = ssl_status.num_unknown_scts;
258 ssl_status.signed_certificate_timestamp_ids; 259 size_t num_invalid_scts = ssl_status.num_invalid_scts;
260 size_t num_valid_scts = ssl_status.num_valid_scts;
259 261
260 size_t num_unknown_scts = 0; 262 blink::WebURLResponse::SignedCertificateTimestampList sctList;
261 size_t num_invalid_scts = 0;
262 size_t num_valid_scts = 0;
263 263
264 SignedCertificateTimestampIDStatusList::iterator iter; 264 for (const auto& sct_and_status : info.signed_certificate_timestamps) {
265 for (iter = sct_list.begin(); iter < sct_list.end(); ++iter) { 265 // Extract SCT's details.
266 switch (iter->status) { 266 blink::WebURLResponse::SignedCertificateTimestamp sct(
267 case net::ct::SCT_STATUS_LOG_UNKNOWN: 267 WebString::fromUTF8(net::ct::StatusToString(sct_and_status.status)),
268 num_unknown_scts++; 268 WebString::fromUTF8(net::ct::OriginToString(sct_and_status.sct->origin)),
269 break; 269 WebString::fromUTF8(
270 case net::ct::SCT_STATUS_INVALID: 270 net::ct::VersionToString(sct_and_status.sct->version)),
271 num_invalid_scts++; 271 WebString::fromUTF8(sct_and_status.sct->log_description),
272 break; 272 WebString::fromUTF8(
273 case net::ct::SCT_STATUS_OK: 273 base::HexEncode(
274 num_valid_scts++; 274 reinterpret_cast<const unsigned char*>(
275 break; 275 sct_and_status.sct->log_id.data()),
276 case net::ct::SCT_STATUS_NONE: 276 sct_and_status.sct->log_id.length())),
277 case net::ct::SCT_STATUS_MAX: 277 sct_and_status.sct->timestamp.ToJavaTime(),
278 // These enum values do not represent SCTs that are taken into account 278 WebString::fromUTF8(
279 // for CT compliance calculations, so we ignore them. 279 net::ct::HashAlgorithmToString(
280 break; 280 sct_and_status.sct->signature.hash_algorithm)),
281 } 281 WebString::fromUTF8(
282 net::ct::SignatureAlgorithmToString(
283 sct_and_status.sct->signature.signature_algorithm)),
284 WebString::fromUTF8(
285 base::HexEncode(
286 reinterpret_cast<const unsigned char*>(
287 sct_and_status.sct->signature.signature_data.data()),
288 sct_and_status.sct->signature.signature_data.length())));
289 sctList.push_back(sct);
282 } 290 }
283 291
284 blink::WebURLResponse::WebSecurityDetails webSecurityDetails( 292 blink::WebURLResponse::WebSecurityDetails webSecurityDetails(
285 WebString::fromUTF8(protocol), WebString::fromUTF8(key_exchange), 293 WebString::fromUTF8(protocol), WebString::fromUTF8(key_exchange),
286 WebString::fromUTF8(cipher), WebString::fromUTF8(mac), 294 WebString::fromUTF8(cipher), WebString::fromUTF8(mac),
287 ssl_status.cert_id, num_unknown_scts, num_invalid_scts, num_valid_scts); 295 ssl_status.cert_id, num_unknown_scts, num_invalid_scts, num_valid_scts,
296 sctList);
288 297
289 response->setSecurityDetails(webSecurityDetails); 298 response->setSecurityDetails(webSecurityDetails);
290 } 299 }
291 300
292 } // namespace 301 } // namespace
293 302
294 // This inner class exists since the WebURLLoader may be deleted while inside a 303 // This inner class exists since the WebURLLoader may be deleted while inside a
295 // call to WebURLLoaderClient. Refcounting is to keep the context from being 304 // call to WebURLLoaderClient. Refcounting is to keep the context from being
296 // deleted if it may have work to do after calling into the client. 305 // deleted if it may have work to do after calling into the client.
297 class WebURLLoaderImpl::Context : public base::RefCounted<Context> { 306 class WebURLLoaderImpl::Context : public base::RefCounted<Context> {
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 response->setWasFallbackRequiredByServiceWorker( 952 response->setWasFallbackRequiredByServiceWorker(
944 info.was_fallback_required_by_service_worker); 953 info.was_fallback_required_by_service_worker);
945 response->setServiceWorkerResponseType(info.response_type_via_service_worker); 954 response->setServiceWorkerResponseType(info.response_type_via_service_worker);
946 response->setOriginalURLViaServiceWorker( 955 response->setOriginalURLViaServiceWorker(
947 info.original_url_via_service_worker); 956 info.original_url_via_service_worker);
948 response->setCacheStorageCacheName( 957 response->setCacheStorageCacheName(
949 info.is_in_cache_storage 958 info.is_in_cache_storage
950 ? blink::WebString::fromUTF8(info.cache_storage_cache_name) 959 ? blink::WebString::fromUTF8(info.cache_storage_cache_name)
951 : blink::WebString()); 960 : blink::WebString());
952 961
953 SetSecurityStyleAndDetails(url, info.security_info, response, 962 SetSecurityStyleAndDetails(url, info, response, report_security_info);
954 report_security_info);
955 963
956 WebURLResponseExtraDataImpl* extra_data = 964 WebURLResponseExtraDataImpl* extra_data =
957 new WebURLResponseExtraDataImpl(info.npn_negotiated_protocol); 965 new WebURLResponseExtraDataImpl(info.npn_negotiated_protocol);
958 response->setExtraData(extra_data); 966 response->setExtraData(extra_data);
959 extra_data->set_was_fetched_via_spdy(info.was_fetched_via_spdy); 967 extra_data->set_was_fetched_via_spdy(info.was_fetched_via_spdy);
960 extra_data->set_was_npn_negotiated(info.was_npn_negotiated); 968 extra_data->set_was_npn_negotiated(info.was_npn_negotiated);
961 extra_data->set_was_alternate_protocol_available( 969 extra_data->set_was_alternate_protocol_available(
962 info.was_alternate_protocol_available); 970 info.was_alternate_protocol_available);
963 extra_data->set_connection_info(info.connection_info); 971 extra_data->set_connection_info(info.connection_info);
964 extra_data->set_was_fetched_via_proxy(info.was_fetched_via_proxy); 972 extra_data->set_was_fetched_via_proxy(info.was_fetched_via_proxy);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 response->clearHTTPHeaderField(webStringName); 1187 response->clearHTTPHeaderField(webStringName);
1180 while (response_headers->EnumerateHeader(&iterator, name, &value)) { 1188 while (response_headers->EnumerateHeader(&iterator, name, &value)) {
1181 response->addHTTPHeaderField(webStringName, 1189 response->addHTTPHeaderField(webStringName,
1182 WebString::fromLatin1(value)); 1190 WebString::fromLatin1(value));
1183 } 1191 }
1184 } 1192 }
1185 return true; 1193 return true;
1186 } 1194 }
1187 1195
1188 } // namespace content 1196 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698