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

Side by Side Diff: content/browser/ssl/ssl_policy.cc

Issue 2296953004: Send certificates to devtools when it's open instead of using certId (Closed)
Patch Set: clear certificates on didstartprovisionalload Created 4 years, 3 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 (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 "content/browser/ssl/ssl_policy.h" 5 #include "content/browser/ssl/ssl_policy.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "content/browser/frame_host/navigation_entry_impl.h" 14 #include "content/browser/frame_host/navigation_entry_impl.h"
15 #include "content/browser/renderer_host/render_process_host_impl.h" 15 #include "content/browser/renderer_host/render_process_host_impl.h"
16 #include "content/browser/renderer_host/render_view_host_impl.h" 16 #include "content/browser/renderer_host/render_view_host_impl.h"
17 #include "content/browser/site_instance_impl.h" 17 #include "content/browser/site_instance_impl.h"
18 #include "content/browser/ssl/ssl_error_handler.h" 18 #include "content/browser/ssl/ssl_error_handler.h"
19 #include "content/browser/web_contents/web_contents_impl.h" 19 #include "content/browser/web_contents/web_contents_impl.h"
20 #include "content/common/security_style_util.h"
20 #include "content/public/browser/content_browser_client.h" 21 #include "content/public/browser/content_browser_client.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
22 #include "content/public/common/resource_type.h" 23 #include "content/public/common/resource_type.h"
23 #include "content/public/common/ssl_status.h" 24 #include "content/public/common/ssl_status.h"
24 #include "content/public/common/url_constants.h" 25 #include "content/public/common/url_constants.h"
25 #include "net/ssl/ssl_info.h" 26 #include "net/ssl/ssl_info.h"
26 #include "url/gurl.h" 27 #include "url/gurl.h"
27 28
28 namespace content { 29 namespace content {
29 30
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 226 }
226 227
227 if (site_instance && 228 if (site_instance &&
228 backend_->DidHostRunContentWithCertErrors( 229 backend_->DidHostRunContentWithCertErrors(
229 entry->GetURL().host(), site_instance->GetProcess()->GetID())) { 230 entry->GetURL().host(), site_instance->GetProcess()->GetID())) {
230 entry->GetSSL().security_style = SECURITY_STYLE_AUTHENTICATION_BROKEN; 231 entry->GetSSL().security_style = SECURITY_STYLE_AUTHENTICATION_BROKEN;
231 entry->GetSSL().content_status |= SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS; 232 entry->GetSSL().content_status |= SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS;
232 } 233 }
233 } 234 }
234 235
235 // Static
236 SecurityStyle SSLPolicy::GetSecurityStyleForResource(
237 const GURL& url,
238 int cert_id,
239 net::CertStatus cert_status) {
240 // An HTTPS response may not have a certificate for some reason. When that
241 // happens, use the unauthenticated (HTTP) rather than the authentication
242 // broken security style so that we can detect this error condition.
243 if (!url.SchemeIsCryptographic() || !cert_id)
244 return SECURITY_STYLE_UNAUTHENTICATED;
245
246 // Minor errors don't lower the security style to
247 // SECURITY_STYLE_AUTHENTICATION_BROKEN.
248 if (net::IsCertStatusError(cert_status) &&
249 !net::IsCertStatusMinorError(cert_status)) {
250 return SECURITY_STYLE_AUTHENTICATION_BROKEN;
251 }
252
253 return SECURITY_STYLE_AUTHENTICATED;
254 }
255
256 //////////////////////////////////////////////////////////////////////////////// 236 ////////////////////////////////////////////////////////////////////////////////
257 // Certificate Error Routines 237 // Certificate Error Routines
258 238
259 void SSLPolicy::OnCertErrorInternal(std::unique_ptr<SSLErrorHandler> handler, 239 void SSLPolicy::OnCertErrorInternal(std::unique_ptr<SSLErrorHandler> handler,
260 int options_mask) { 240 int options_mask) {
261 bool overridable = (options_mask & OVERRIDABLE) != 0; 241 bool overridable = (options_mask & OVERRIDABLE) != 0;
262 bool strict_enforcement = (options_mask & STRICT_ENFORCEMENT) != 0; 242 bool strict_enforcement = (options_mask & STRICT_ENFORCEMENT) != 0;
263 bool expired_previous_decision = 243 bool expired_previous_decision =
264 (options_mask & EXPIRED_PREVIOUS_DECISION) != 0; 244 (options_mask & EXPIRED_PREVIOUS_DECISION) != 0;
265 245
266 WebContents* web_contents = handler->web_contents(); 246 WebContents* web_contents = handler->web_contents();
267 int cert_error = handler->cert_error(); 247 int cert_error = handler->cert_error();
268 const net::SSLInfo& ssl_info = handler->ssl_info(); 248 const net::SSLInfo& ssl_info = handler->ssl_info();
269 const GURL& request_url = handler->request_url(); 249 const GURL& request_url = handler->request_url();
270 ResourceType resource_type = handler->resource_type(); 250 ResourceType resource_type = handler->resource_type();
271 GetContentClient()->browser()->AllowCertificateError( 251 GetContentClient()->browser()->AllowCertificateError(
272 web_contents, cert_error, ssl_info, request_url, resource_type, 252 web_contents, cert_error, ssl_info, request_url, resource_type,
273 overridable, strict_enforcement, expired_previous_decision, 253 overridable, strict_enforcement, expired_previous_decision,
274 base::Bind(&OnAllowCertificate, base::Owned(handler.release()), this)); 254 base::Bind(&OnAllowCertificate, base::Owned(handler.release()), this));
275 } 255 }
276 256
277 void SSLPolicy::InitializeEntryIfNeeded(NavigationEntryImpl* entry) { 257 void SSLPolicy::InitializeEntryIfNeeded(NavigationEntryImpl* entry) {
278 if (entry->GetSSL().security_style != SECURITY_STYLE_UNKNOWN) 258 if (entry->GetSSL().security_style != SECURITY_STYLE_UNKNOWN)
279 return; 259 return;
280 260
281 entry->GetSSL().security_style = GetSecurityStyleForResource( 261 entry->GetSSL().security_style = GetSecurityStyleForResource(
282 entry->GetURL(), entry->GetSSL().cert_id, entry->GetSSL().cert_status); 262 entry->GetURL(), !!entry->GetSSL().cert_id, entry->GetSSL().cert_status);
283 } 263 }
284 264
285 } // namespace content 265 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698