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

Side by Side Diff: net/url_request/url_request_http_job.cc

Issue 8865006: net: move pinning checks into the SSL socket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « net/socket/ssl_client_socket_nss.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "net/url_request/url_request_http_job.h" 5 #include "net/url_request/url_request_http_job.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/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/build_time.h"
11 #include "base/command_line.h" 10 #include "base/command_line.h"
12 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
13 #include "base/file_util.h" 12 #include "base/file_util.h"
14 #include "base/file_version_info.h" 13 #include "base/file_version_info.h"
15 #include "base/message_loop.h" 14 #include "base/message_loop.h"
16 #include "base/metrics/field_trial.h" 15 #include "base/metrics/field_trial.h"
17 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
18 #include "base/rand_util.h" 17 #include "base/rand_util.h"
19 #include "base/string_util.h" 18 #include "base/string_util.h"
20 #include "base/time.h" 19 #include "base/time.h"
21 #include "net/base/cert_status_flags.h" 20 #include "net/base/cert_status_flags.h"
22 #include "net/base/cookie_monster.h" 21 #include "net/base/cookie_monster.h"
23 #include "net/base/filter.h" 22 #include "net/base/filter.h"
24 #include "net/base/host_port_pair.h" 23 #include "net/base/host_port_pair.h"
25 #include "net/base/load_flags.h" 24 #include "net/base/load_flags.h"
26 #include "net/base/mime_util.h" 25 #include "net/base/mime_util.h"
27 #include "net/base/net_errors.h" 26 #include "net/base/net_errors.h"
28 #include "net/base/net_util.h" 27 #include "net/base/net_util.h"
29 #include "net/base/network_delegate.h" 28 #include "net/base/network_delegate.h"
30 #include "net/base/sdch_manager.h" 29 #include "net/base/sdch_manager.h"
31 #include "net/base/ssl_cert_request_info.h" 30 #include "net/base/ssl_cert_request_info.h"
32 #include "net/base/ssl_config_service.h" 31 #include "net/base/ssl_config_service.h"
33 #include "net/base/transport_security_state.h"
34 #include "net/http/http_mac_signature.h" 32 #include "net/http/http_mac_signature.h"
35 #include "net/http/http_request_headers.h" 33 #include "net/http/http_request_headers.h"
36 #include "net/http/http_response_headers.h" 34 #include "net/http/http_response_headers.h"
37 #include "net/http/http_response_info.h" 35 #include "net/http/http_response_info.h"
38 #include "net/http/http_transaction.h" 36 #include "net/http/http_transaction.h"
39 #include "net/http/http_transaction_factory.h" 37 #include "net/http/http_transaction_factory.h"
40 #include "net/http/http_util.h" 38 #include "net/http/http_util.h"
41 #include "net/url_request/fraudulent_certificate_reporter.h" 39 #include "net/url_request/fraudulent_certificate_reporter.h"
42 #include "net/url_request/url_request.h" 40 #include "net/url_request/url_request.h"
43 #include "net/url_request/url_request_context.h" 41 #include "net/url_request/url_request_context.h"
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 return; 652 return;
655 653
656 // If the transaction was destroyed, then the job was cancelled, and 654 // If the transaction was destroyed, then the job was cancelled, and
657 // we can just ignore this notification. 655 // we can just ignore this notification.
658 if (!transaction_.get()) 656 if (!transaction_.get())
659 return; 657 return;
660 658
661 // Clear the IO_PENDING status 659 // Clear the IO_PENDING status
662 SetStatus(URLRequestStatus()); 660 SetStatus(URLRequestStatus());
663 661
664 #if defined(OFFICIAL_BUILD) && !defined(OS_ANDROID) 662 if (result == ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN &&
665 // Take care of any mandates for public key pinning. 663 transaction_->GetResponseInfo() != NULL) {
666 // 664 FraudulentCertificateReporter* reporter =
667 // Pinning is only enabled for official builds to make sure that others don't 665 context_->fraudulent_certificate_reporter();
668 // end up with pins that cannot be easily updated. 666 if (reporter != NULL) {
669 // 667 const SSLInfo& ssl_info = transaction_->GetResponseInfo()->ssl_info;
670 // TODO(agl): we might have an issue here where a request for foo.example.com
671 // merges into a SPDY connection to www.example.com, and gets a different
672 // certificate.
673 if (transaction_->GetResponseInfo() != NULL) {
674 const SSLInfo& ssl_info = transaction_->GetResponseInfo()->ssl_info;
675 if (ssl_info.is_valid() &&
676 (result == OK || (IsCertificateError(result) &&
677 IsCertStatusMinorError(ssl_info.cert_status))) &&
678 ssl_info.is_issued_by_known_root &&
679 context_->transport_security_state()) {
680 TransportSecurityState::DomainState domain_state;
681 bool sni_available = SSLConfigService::IsSNIAvailable( 668 bool sni_available = SSLConfigService::IsSNIAvailable(
682 context_->ssl_config_service()); 669 context_->ssl_config_service());
683 std::string host = request_->url().host(); 670 const std::string& host = request_->url().host();
684 671
685 if (context_->transport_security_state()->HasPinsForHost( 672 reporter->SendReport(host, ssl_info, sni_available);
686 &domain_state, host, sni_available)) {
687 if (!domain_state.IsChainOfPublicKeysPermitted(
688 ssl_info.public_key_hashes)) {
689 const base::Time build_time = base::GetBuildTime();
690 // Pins are not enforced if the build is sufficiently old. Chrome
691 // users should get updates every six weeks or so, but it's possible
692 // that some users will stop getting updates for some reason. We
693 // don't want those users building up as a pool of people with bad
694 // pins.
695 if ((base::Time::Now() - build_time).InDays() < 70 /* 10 weeks */) {
696 result = ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN;
697 UMA_HISTOGRAM_BOOLEAN("Net.PublicKeyPinSuccess", false);
698 TransportSecurityState::ReportUMAOnPinFailure(host);
699 FraudulentCertificateReporter* reporter =
700 context_->fraudulent_certificate_reporter();
701 if (reporter != NULL)
702 reporter->SendReport(host, ssl_info, sni_available);
703 }
704 } else {
705 UMA_HISTOGRAM_BOOLEAN("Net.PublicKeyPinSuccess", true);
706 }
707 }
708 } 673 }
709 } 674 }
710 #endif
711 675
712 if (result == OK) { 676 if (result == OK) {
713 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders(); 677 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders();
714 if (request_->context() && request_->context()->network_delegate()) { 678 if (request_->context() && request_->context()->network_delegate()) {
715 // Note that |this| may not be deleted until 679 // Note that |this| may not be deleted until
716 // |on_headers_received_callback_| or 680 // |on_headers_received_callback_| or
717 // |NetworkDelegate::URLRequestDestroyed()| has been called. 681 // |NetworkDelegate::URLRequestDestroyed()| has been called.
718 int error = request_->context()->network_delegate()-> 682 int error = request_->context()->network_delegate()->
719 NotifyHeadersReceived(request_, on_headers_received_callback_, 683 NotifyHeadersReceived(request_, on_headers_received_callback_,
720 headers, &override_response_headers_); 684 headers, &override_response_headers_);
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 return override_response_headers_.get() ? 1376 return override_response_headers_.get() ?
1413 override_response_headers_ : 1377 override_response_headers_ :
1414 transaction_->GetResponseInfo()->headers; 1378 transaction_->GetResponseInfo()->headers;
1415 } 1379 }
1416 1380
1417 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1381 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1418 awaiting_callback_ = false; 1382 awaiting_callback_ = false;
1419 } 1383 }
1420 1384
1421 } // namespace net 1385 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_nss.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698