Chromium Code Reviews| 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 "content/browser/ssl/ssl_manager.h" | 5 #include "content/browser/ssl/ssl_manager.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 } | 118 } |
| 119 return; | 119 return; |
| 120 } | 120 } |
| 121 | 121 |
| 122 NavigationControllerImpl* controller = | 122 NavigationControllerImpl* controller = |
| 123 static_cast<NavigationControllerImpl*>(&web_contents->GetController()); | 123 static_cast<NavigationControllerImpl*>(&web_contents->GetController()); |
| 124 controller->SetPendingNavigationSSLError(true); | 124 controller->SetPendingNavigationSSLError(true); |
| 125 | 125 |
| 126 SSLManager* manager = controller->ssl_manager(); | 126 SSLManager* manager = controller->ssl_manager(); |
| 127 manager->OnCertError(std::move(handler)); | 127 manager->OnCertError(std::move(handler)); |
| 128 // On Android, OnCertError can cause a Java exception to be thrown - in such a | |
| 129 // case we cannot allow calls back into Java here. If adding any additional | |
| 130 // code here, make sure it cannot call into Java. | |
| 128 } | 131 } |
| 129 | 132 |
| 130 } // namespace | 133 } // namespace |
| 131 | 134 |
| 132 // static | 135 // static |
| 133 void SSLManager::OnSSLCertificateError( | 136 void SSLManager::OnSSLCertificateError( |
| 134 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate, | 137 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate, |
| 135 const ResourceType resource_type, | 138 const ResourceType resource_type, |
| 136 const GURL& url, | 139 const GURL& url, |
| 137 const base::Callback<WebContents*(void)>& web_contents_getter, | 140 const base::Callback<WebContents*(void)>& web_contents_getter, |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION: | 306 case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION: |
| 304 case net::ERR_CERT_VALIDITY_TOO_LONG: | 307 case net::ERR_CERT_VALIDITY_TOO_LONG: |
| 305 case net::ERR_CERTIFICATE_TRANSPARENCY_REQUIRED: | 308 case net::ERR_CERTIFICATE_TRANSPARENCY_REQUIRED: |
| 306 if (!handler->fatal()) | 309 if (!handler->fatal()) |
| 307 options_mask |= OVERRIDABLE; | 310 options_mask |= OVERRIDABLE; |
| 308 else | 311 else |
| 309 options_mask |= STRICT_ENFORCEMENT; | 312 options_mask |= STRICT_ENFORCEMENT; |
| 310 if (expired_previous_decision) | 313 if (expired_previous_decision) |
| 311 options_mask |= EXPIRED_PREVIOUS_DECISION; | 314 options_mask |= EXPIRED_PREVIOUS_DECISION; |
| 312 OnCertErrorInternal(std::move(handler), options_mask); | 315 OnCertErrorInternal(std::move(handler), options_mask); |
| 316 // On Android, OnCertErrorInternal can cause a Java exception to be thrown | |
| 317 // - in such a case we cannot allow calls back into Java here. If adding | |
| 318 // any additional code here, make sure it cannot call into Java. | |
|
estark
2017/05/11 00:50:56
Hmm, I don't think I understand this. Is it a prob
gsennton
2017/05/11 12:17:17
Yes, so what happens is this:
OnCertErrorInternal(
| |
| 313 break; | 319 break; |
| 314 case net::ERR_CERT_NO_REVOCATION_MECHANISM: | 320 case net::ERR_CERT_NO_REVOCATION_MECHANISM: |
| 315 // Ignore this error. | 321 // Ignore this error. |
| 316 handler->ContinueRequest(); | 322 handler->ContinueRequest(); |
| 317 break; | 323 break; |
| 318 case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION: | 324 case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION: |
| 319 // We ignore this error but will show a warning status in the location | 325 // We ignore this error but will show a warning status in the location |
| 320 // bar. | 326 // bar. |
| 321 handler->ContinueRequest(); | 327 handler->ContinueRequest(); |
| 322 break; | 328 break; |
| 323 case net::ERR_CERT_CONTAINS_ERRORS: | 329 case net::ERR_CERT_CONTAINS_ERRORS: |
| 324 case net::ERR_CERT_REVOKED: | 330 case net::ERR_CERT_REVOKED: |
| 325 case net::ERR_CERT_INVALID: | 331 case net::ERR_CERT_INVALID: |
| 326 case net::ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY: | 332 case net::ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY: |
| 327 case net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN: | 333 case net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN: |
| 328 if (handler->fatal()) | 334 if (handler->fatal()) |
| 329 options_mask |= STRICT_ENFORCEMENT; | 335 options_mask |= STRICT_ENFORCEMENT; |
| 330 if (expired_previous_decision) | 336 if (expired_previous_decision) |
| 331 options_mask |= EXPIRED_PREVIOUS_DECISION; | 337 options_mask |= EXPIRED_PREVIOUS_DECISION; |
| 332 OnCertErrorInternal(std::move(handler), options_mask); | 338 OnCertErrorInternal(std::move(handler), options_mask); |
| 339 // On Android, OnCertErrorInternal can cause a Java exception to be thrown | |
| 340 // - in such a case we cannot allow calls back into Java here. If adding | |
| 341 // any additional code here, make sure it cannot call into Java. | |
| 333 break; | 342 break; |
| 334 default: | 343 default: |
| 335 NOTREACHED(); | 344 NOTREACHED(); |
| 336 handler->CancelRequest(); | 345 handler->CancelRequest(); |
| 337 break; | 346 break; |
| 338 } | 347 } |
| 339 } | 348 } |
| 340 | 349 |
| 341 void SSLManager::DidStartResourceResponse(const GURL& url, | 350 void SSLManager::DidStartResourceResponse(const GURL& url, |
| 342 bool has_certificate, | 351 bool has_certificate, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 protocol::SecurityHandler* security_handler = | 395 protocol::SecurityHandler* security_handler = |
| 387 protocol::SecurityHandler::FromAgentHost(agent_host); | 396 protocol::SecurityHandler::FromAgentHost(agent_host); |
| 388 if (!security_handler || | 397 if (!security_handler || |
| 389 !security_handler->NotifyCertificateError( | 398 !security_handler->NotifyCertificateError( |
| 390 cert_error, request_url, | 399 cert_error, request_url, |
| 391 base::Bind(&OnAllowCertificateWithRecordDecision, false, callback))) { | 400 base::Bind(&OnAllowCertificateWithRecordDecision, false, callback))) { |
| 392 GetContentClient()->browser()->AllowCertificateError( | 401 GetContentClient()->browser()->AllowCertificateError( |
| 393 web_contents, cert_error, ssl_info, request_url, resource_type, | 402 web_contents, cert_error, ssl_info, request_url, resource_type, |
| 394 overridable, strict_enforcement, expired_previous_decision, | 403 overridable, strict_enforcement, expired_previous_decision, |
| 395 base::Bind(&OnAllowCertificateWithRecordDecision, true, callback)); | 404 base::Bind(&OnAllowCertificateWithRecordDecision, true, callback)); |
| 405 // On Android, AllowCertificateError can cause a Java exception to be thrown | |
| 406 // - in such a case we cannot allow calls back into Java here. If adding any | |
| 407 // additional code here, make sure it cannot call into Java. | |
| 396 } | 408 } |
| 397 } | 409 } |
| 398 | 410 |
| 399 void SSLManager::UpdateEntry(NavigationEntryImpl* entry, | 411 void SSLManager::UpdateEntry(NavigationEntryImpl* entry, |
| 400 int add_content_status_flags, | 412 int add_content_status_flags, |
| 401 int remove_content_status_flags) { | 413 int remove_content_status_flags) { |
| 402 // We don't always have a navigation entry to update, for example in the | 414 // We don't always have a navigation entry to update, for example in the |
| 403 // case of the Web Inspector. | 415 // case of the Web Inspector. |
| 404 if (!entry) | 416 if (!entry) |
| 405 return; | 417 return; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 SSLManagerSet* managers = | 466 SSLManagerSet* managers = |
| 455 static_cast<SSLManagerSet*>(context->GetUserData(kSSLManagerKeyName)); | 467 static_cast<SSLManagerSet*>(context->GetUserData(kSSLManagerKeyName)); |
| 456 | 468 |
| 457 for (std::set<SSLManager*>::iterator i = managers->get().begin(); | 469 for (std::set<SSLManager*>::iterator i = managers->get().begin(); |
| 458 i != managers->get().end(); ++i) { | 470 i != managers->get().end(); ++i) { |
| 459 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry(), 0, 0); | 471 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry(), 0, 0); |
| 460 } | 472 } |
| 461 } | 473 } |
| 462 | 474 |
| 463 } // namespace content | 475 } // namespace content |
| OLD | NEW |