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

Side by Side Diff: net/socket/ssl_client_socket_nss.cc

Issue 356713005: Rename ServerBoundCert => ChannelID to reflect the current name (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix cookies_list.js Created 6 years, 5 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 | Annotate | Revision Log
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 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived 5 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived
6 // from AuthCertificateCallback() in 6 // from AuthCertificateCallback() in
7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. 7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp.
8 8
9 /* ***** BEGIN LICENSE BLOCK ***** 9 /* ***** BEGIN LICENSE BLOCK *****
10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 // 505 //
506 // In the single-threaded mode (where the network and NSS task runners run on 506 // In the single-threaded mode (where the network and NSS task runners run on
507 // the same thread), these are all attempted synchronously, while in the 507 // the same thread), these are all attempted synchronously, while in the
508 // multi-threaded mode, message passing is used. 508 // multi-threaded mode, message passing is used.
509 // 509 //
510 // 1) NSS Task Runner: Execute NSS function (DoPayloadRead, DoPayloadWrite, 510 // 1) NSS Task Runner: Execute NSS function (DoPayloadRead, DoPayloadWrite,
511 // DoHandshake) 511 // DoHandshake)
512 // 2) NSS Task Runner: Prepare data to go from NSS to an IO function: 512 // 2) NSS Task Runner: Prepare data to go from NSS to an IO function:
513 // (BufferRecv, BufferSend) 513 // (BufferRecv, BufferSend)
514 // 3) Network Task Runner: Perform IO on that data (DoBufferRecv, 514 // 3) Network Task Runner: Perform IO on that data (DoBufferRecv,
515 // DoBufferSend, DoGetDomainBoundCert, OnGetDomainBoundCertComplete) 515 // DoBufferSend, DoGetChannelID, OnGetChannelIDComplete)
516 // 4) Both Task Runners: Callback for asynchronous completion or to marshal 516 // 4) Both Task Runners: Callback for asynchronous completion or to marshal
517 // data from the network task runner back to NSS (BufferRecvComplete, 517 // data from the network task runner back to NSS (BufferRecvComplete,
518 // BufferSendComplete, OnHandshakeIOComplete) 518 // BufferSendComplete, OnHandshakeIOComplete)
519 // 519 //
520 ///////////////////////////////////////////////////////////////////////////// 520 /////////////////////////////////////////////////////////////////////////////
521 // Single-threaded example 521 // Single-threaded example
522 // 522 //
523 // |--------------------------Network Task Runner--------------------------| 523 // |--------------------------Network Task Runner--------------------------|
524 // SSLClientSocketNSS Core (Transport Socket) 524 // SSLClientSocketNSS Core (Transport Socket)
525 // Read() 525 // Read()
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 class SSLClientSocketNSS::Core : public base::RefCountedThreadSafe<Core> { 573 class SSLClientSocketNSS::Core : public base::RefCountedThreadSafe<Core> {
574 public: 574 public:
575 // Creates a new Core. 575 // Creates a new Core.
576 // 576 //
577 // Any calls to NSS are executed on the |nss_task_runner|, while any calls 577 // Any calls to NSS are executed on the |nss_task_runner|, while any calls
578 // that need to operate on the underlying transport, net log, or server 578 // that need to operate on the underlying transport, net log, or server
579 // bound certificate fetching will happen on the |network_task_runner|, so 579 // bound certificate fetching will happen on the |network_task_runner|, so
580 // that their lifetimes match that of the owning SSLClientSocketNSS. 580 // that their lifetimes match that of the owning SSLClientSocketNSS.
581 // 581 //
582 // The caller retains ownership of |transport|, |net_log|, and 582 // The caller retains ownership of |transport|, |net_log|, and
583 // |server_bound_cert_service|, and they will not be accessed once Detach() 583 // |channel_id_service|, and they will not be accessed once Detach()
584 // has been called. 584 // has been called.
585 Core(base::SequencedTaskRunner* network_task_runner, 585 Core(base::SequencedTaskRunner* network_task_runner,
586 base::SequencedTaskRunner* nss_task_runner, 586 base::SequencedTaskRunner* nss_task_runner,
587 ClientSocketHandle* transport, 587 ClientSocketHandle* transport,
588 const HostPortPair& host_and_port, 588 const HostPortPair& host_and_port,
589 const SSLConfig& ssl_config, 589 const SSLConfig& ssl_config,
590 BoundNetLog* net_log, 590 BoundNetLog* net_log,
591 ServerBoundCertService* server_bound_cert_service); 591 ChannelIDService* channel_id_service);
592 592
593 // Called on the network task runner. 593 // Called on the network task runner.
594 // Transfers ownership of |socket|, an NSS SSL socket, and |buffers|, the 594 // Transfers ownership of |socket|, an NSS SSL socket, and |buffers|, the
595 // underlying memio implementation, to the Core. Returns true if the Core 595 // underlying memio implementation, to the Core. Returns true if the Core
596 // was successfully registered with the socket. 596 // was successfully registered with the socket.
597 bool Init(PRFileDesc* socket, memio_Private* buffers); 597 bool Init(PRFileDesc* socket, memio_Private* buffers);
598 598
599 // Called on the network task runner. 599 // Called on the network task runner.
600 // 600 //
601 // Attempts to perform an SSL handshake. If the handshake cannot be 601 // Attempts to perform an SSL handshake. If the handshake cannot be
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 static SECStatus ClientChannelIDHandler( 735 static SECStatus ClientChannelIDHandler(
736 void* arg, 736 void* arg,
737 PRFileDesc* socket, 737 PRFileDesc* socket,
738 SECKEYPublicKey **out_public_key, 738 SECKEYPublicKey **out_public_key,
739 SECKEYPrivateKey **out_private_key); 739 SECKEYPrivateKey **out_private_key);
740 740
741 // ImportChannelIDKeys is a helper function for turning a DER-encoded cert and 741 // ImportChannelIDKeys is a helper function for turning a DER-encoded cert and
742 // key into a SECKEYPublicKey and SECKEYPrivateKey. Returns OK upon success 742 // key into a SECKEYPublicKey and SECKEYPrivateKey. Returns OK upon success
743 // and an error code otherwise. 743 // and an error code otherwise.
744 // Requires |domain_bound_private_key_| and |domain_bound_cert_| to have been 744 // Requires |domain_bound_private_key_| and |domain_bound_cert_| to have been
745 // set by a call to ServerBoundCertService->GetDomainBoundCert. The caller 745 // set by a call to ChannelIDService->GetChannelID. The caller
746 // takes ownership of the |*cert| and |*key|. 746 // takes ownership of the |*cert| and |*key|.
747 int ImportChannelIDKeys(SECKEYPublicKey** public_key, SECKEYPrivateKey** key); 747 int ImportChannelIDKeys(SECKEYPublicKey** public_key, SECKEYPrivateKey** key);
748 748
749 // Updates the NSS and platform specific certificates. 749 // Updates the NSS and platform specific certificates.
750 void UpdateServerCert(); 750 void UpdateServerCert();
751 // Update the nss_handshake_state_ with the SignedCertificateTimestampList 751 // Update the nss_handshake_state_ with the SignedCertificateTimestampList
752 // received in the handshake via a TLS extension. 752 // received in the handshake via a TLS extension.
753 void UpdateSignedCertTimestamps(); 753 void UpdateSignedCertTimestamps();
754 // Update the OCSP response cache with the stapled response received in the 754 // Update the OCSP response cache with the stapled response received in the
755 // handshake, and update nss_handshake_state_ with 755 // handshake, and update nss_handshake_state_ with
756 // the SignedCertificateTimestampList received in the stapled OCSP response. 756 // the SignedCertificateTimestampList received in the stapled OCSP response.
757 void UpdateStapledOCSPResponse(); 757 void UpdateStapledOCSPResponse();
758 // Updates the nss_handshake_state_ with the negotiated security parameters. 758 // Updates the nss_handshake_state_ with the negotiated security parameters.
759 void UpdateConnectionStatus(); 759 void UpdateConnectionStatus();
760 // Record histograms for channel id support during full handshakes - resumed 760 // Record histograms for channel id support during full handshakes - resumed
761 // handshakes are ignored. 761 // handshakes are ignored.
762 void RecordChannelIDSupportOnNSSTaskRunner(); 762 void RecordChannelIDSupportOnNSSTaskRunner();
763 // UpdateNextProto gets any application-layer protocol that may have been 763 // UpdateNextProto gets any application-layer protocol that may have been
764 // negotiated by the TLS connection. 764 // negotiated by the TLS connection.
765 void UpdateNextProto(); 765 void UpdateNextProto();
766 766
767 //////////////////////////////////////////////////////////////////////////// 767 ////////////////////////////////////////////////////////////////////////////
768 // Methods that are ONLY called on the network task runner: 768 // Methods that are ONLY called on the network task runner:
769 //////////////////////////////////////////////////////////////////////////// 769 ////////////////////////////////////////////////////////////////////////////
770 int DoBufferRecv(IOBuffer* buffer, int len); 770 int DoBufferRecv(IOBuffer* buffer, int len);
771 int DoBufferSend(IOBuffer* buffer, int len); 771 int DoBufferSend(IOBuffer* buffer, int len);
772 int DoGetDomainBoundCert(const std::string& host); 772 int DoGetChannelID(const std::string& host);
773 773
774 void OnGetDomainBoundCertComplete(int result); 774 void OnGetChannelIDComplete(int result);
775 void OnHandshakeStateUpdated(const HandshakeState& state); 775 void OnHandshakeStateUpdated(const HandshakeState& state);
776 void OnNSSBufferUpdated(int amount_in_read_buffer); 776 void OnNSSBufferUpdated(int amount_in_read_buffer);
777 void DidNSSRead(int result); 777 void DidNSSRead(int result);
778 void DidNSSWrite(int result); 778 void DidNSSWrite(int result);
779 void RecordChannelIDSupportOnNetworkTaskRunner( 779 void RecordChannelIDSupportOnNetworkTaskRunner(
780 bool negotiated_channel_id, 780 bool negotiated_channel_id,
781 bool channel_id_enabled, 781 bool channel_id_enabled,
782 bool supports_ecc) const; 782 bool supports_ecc) const;
783 783
784 //////////////////////////////////////////////////////////////////////////// 784 ////////////////////////////////////////////////////////////////////////////
(...skipping 28 matching lines...) Expand all
813 bool detached_; 813 bool detached_;
814 814
815 // The underlying transport to use for network IO. 815 // The underlying transport to use for network IO.
816 ClientSocketHandle* transport_; 816 ClientSocketHandle* transport_;
817 base::WeakPtrFactory<BoundNetLog> weak_net_log_factory_; 817 base::WeakPtrFactory<BoundNetLog> weak_net_log_factory_;
818 818
819 // The current handshake state. Mirrors |nss_handshake_state_|. 819 // The current handshake state. Mirrors |nss_handshake_state_|.
820 HandshakeState network_handshake_state_; 820 HandshakeState network_handshake_state_;
821 821
822 // The service for retrieving Channel ID keys. May be NULL. 822 // The service for retrieving Channel ID keys. May be NULL.
823 ServerBoundCertService* server_bound_cert_service_; 823 ChannelIDService* channel_id_service_;
824 ServerBoundCertService::RequestHandle domain_bound_cert_request_handle_; 824 ChannelIDService::RequestHandle domain_bound_cert_request_handle_;
825 825
826 // The information about NSS task runner. 826 // The information about NSS task runner.
827 int unhandled_buffer_size_; 827 int unhandled_buffer_size_;
828 bool nss_waiting_read_; 828 bool nss_waiting_read_;
829 bool nss_waiting_write_; 829 bool nss_waiting_write_;
830 bool nss_is_closed_; 830 bool nss_is_closed_;
831 831
832 // Set when Read() or Write() successfully reads or writes data to or from the 832 // Set when Read() or Write() successfully reads or writes data to or from the
833 // network. 833 // network.
834 bool was_ever_used_; 834 bool was_ever_used_;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 // Members that are accessed on both the network task runner and the NSS 895 // Members that are accessed on both the network task runner and the NSS
896 // task runner. 896 // task runner.
897 //////////////////////////////////////////////////////////////////////////// 897 ////////////////////////////////////////////////////////////////////////////
898 scoped_refptr<base::SequencedTaskRunner> network_task_runner_; 898 scoped_refptr<base::SequencedTaskRunner> network_task_runner_;
899 scoped_refptr<base::SequencedTaskRunner> nss_task_runner_; 899 scoped_refptr<base::SequencedTaskRunner> nss_task_runner_;
900 900
901 // Dereferenced only on the network task runner, but bound to tasks destined 901 // Dereferenced only on the network task runner, but bound to tasks destined
902 // for the network task runner from the NSS task runner. 902 // for the network task runner from the NSS task runner.
903 base::WeakPtr<BoundNetLog> weak_net_log_; 903 base::WeakPtr<BoundNetLog> weak_net_log_;
904 904
905 // Written on the network task runner by the |server_bound_cert_service_|, 905 // Written on the network task runner by the |channel_id_service_|,
906 // prior to invoking OnHandshakeIOComplete. 906 // prior to invoking OnHandshakeIOComplete.
907 // Read on the NSS task runner when once OnHandshakeIOComplete is invoked 907 // Read on the NSS task runner when once OnHandshakeIOComplete is invoked
908 // on the NSS task runner. 908 // on the NSS task runner.
909 std::string domain_bound_private_key_; 909 std::string domain_bound_private_key_;
910 std::string domain_bound_cert_; 910 std::string domain_bound_cert_;
911 911
912 DISALLOW_COPY_AND_ASSIGN(Core); 912 DISALLOW_COPY_AND_ASSIGN(Core);
913 }; 913 };
914 914
915 SSLClientSocketNSS::Core::Core( 915 SSLClientSocketNSS::Core::Core(
916 base::SequencedTaskRunner* network_task_runner, 916 base::SequencedTaskRunner* network_task_runner,
917 base::SequencedTaskRunner* nss_task_runner, 917 base::SequencedTaskRunner* nss_task_runner,
918 ClientSocketHandle* transport, 918 ClientSocketHandle* transport,
919 const HostPortPair& host_and_port, 919 const HostPortPair& host_and_port,
920 const SSLConfig& ssl_config, 920 const SSLConfig& ssl_config,
921 BoundNetLog* net_log, 921 BoundNetLog* net_log,
922 ServerBoundCertService* server_bound_cert_service) 922 ChannelIDService* channel_id_service)
923 : detached_(false), 923 : detached_(false),
924 transport_(transport), 924 transport_(transport),
925 weak_net_log_factory_(net_log), 925 weak_net_log_factory_(net_log),
926 server_bound_cert_service_(server_bound_cert_service), 926 channel_id_service_(channel_id_service),
927 unhandled_buffer_size_(0), 927 unhandled_buffer_size_(0),
928 nss_waiting_read_(false), 928 nss_waiting_read_(false),
929 nss_waiting_write_(false), 929 nss_waiting_write_(false),
930 nss_is_closed_(false), 930 nss_is_closed_(false),
931 was_ever_used_(false), 931 was_ever_used_(false),
932 host_and_port_(host_and_port), 932 host_and_port_(host_and_port),
933 ssl_config_(ssl_config), 933 ssl_config_(ssl_config),
934 nss_fd_(NULL), 934 nss_fd_(NULL),
935 nss_bufs_(NULL), 935 nss_bufs_(NULL),
936 pending_read_result_(kNoPendingReadResult), 936 pending_read_result_(kNoPendingReadResult),
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 this); 1019 this);
1020 #else 1020 #else
1021 rv = SSL_GetClientAuthDataHook( 1021 rv = SSL_GetClientAuthDataHook(
1022 nss_fd_, SSLClientSocketNSS::Core::ClientAuthHandler, this); 1022 nss_fd_, SSLClientSocketNSS::Core::ClientAuthHandler, this);
1023 #endif 1023 #endif
1024 if (rv != SECSuccess) { 1024 if (rv != SECSuccess) {
1025 LogFailedNSSFunction(*weak_net_log_, "SSL_GetClientAuthDataHook", ""); 1025 LogFailedNSSFunction(*weak_net_log_, "SSL_GetClientAuthDataHook", "");
1026 return false; 1026 return false;
1027 } 1027 }
1028 1028
1029 if (IsChannelIDEnabled(ssl_config_, server_bound_cert_service_)) { 1029 if (IsChannelIDEnabled(ssl_config_, channel_id_service_)) {
1030 rv = SSL_SetClientChannelIDCallback( 1030 rv = SSL_SetClientChannelIDCallback(
1031 nss_fd_, SSLClientSocketNSS::Core::ClientChannelIDHandler, this); 1031 nss_fd_, SSLClientSocketNSS::Core::ClientChannelIDHandler, this);
1032 if (rv != SECSuccess) { 1032 if (rv != SECSuccess) {
1033 LogFailedNSSFunction( 1033 LogFailedNSSFunction(
1034 *weak_net_log_, "SSL_SetClientChannelIDCallback", ""); 1034 *weak_net_log_, "SSL_SetClientChannelIDCallback", "");
1035 } 1035 }
1036 } 1036 }
1037 1037
1038 rv = SSL_SetCanFalseStartCallback( 1038 rv = SSL_SetCanFalseStartCallback(
1039 nss_fd_, SSLClientSocketNSS::Core::CanFalseStartCallback, this); 1039 nss_fd_, SSLClientSocketNSS::Core::CanFalseStartCallback, this);
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
2277 core->PostOrRunCallback( 2277 core->PostOrRunCallback(
2278 FROM_HERE, 2278 FROM_HERE,
2279 base::Bind(&AddLogEvent, core->weak_net_log_, 2279 base::Bind(&AddLogEvent, core->weak_net_log_,
2280 NetLog::TYPE_SSL_CHANNEL_ID_REQUESTED)); 2280 NetLog::TYPE_SSL_CHANNEL_ID_REQUESTED));
2281 2281
2282 // We have negotiated the TLS channel ID extension. 2282 // We have negotiated the TLS channel ID extension.
2283 core->channel_id_xtn_negotiated_ = true; 2283 core->channel_id_xtn_negotiated_ = true;
2284 std::string host = core->host_and_port_.host(); 2284 std::string host = core->host_and_port_.host();
2285 int error = ERR_UNEXPECTED; 2285 int error = ERR_UNEXPECTED;
2286 if (core->OnNetworkTaskRunner()) { 2286 if (core->OnNetworkTaskRunner()) {
2287 error = core->DoGetDomainBoundCert(host); 2287 error = core->DoGetChannelID(host);
2288 } else { 2288 } else {
2289 bool posted = core->network_task_runner_->PostTask( 2289 bool posted = core->network_task_runner_->PostTask(
2290 FROM_HERE, 2290 FROM_HERE,
2291 base::Bind( 2291 base::Bind(
2292 IgnoreResult(&Core::DoGetDomainBoundCert), 2292 IgnoreResult(&Core::DoGetChannelID),
2293 core, host)); 2293 core, host));
2294 error = posted ? ERR_IO_PENDING : ERR_ABORTED; 2294 error = posted ? ERR_IO_PENDING : ERR_ABORTED;
2295 } 2295 }
2296 2296
2297 if (error == ERR_IO_PENDING) { 2297 if (error == ERR_IO_PENDING) {
2298 // Asynchronous case. 2298 // Asynchronous case.
2299 core->channel_id_needed_ = true; 2299 core->channel_id_needed_ = true;
2300 return SECWouldBlock; 2300 return SECWouldBlock;
2301 } 2301 }
2302 2302
(...skipping 27 matching lines...) Expand all
2330 NULL, 2330 NULL,
2331 PR_FALSE, 2331 PR_FALSE,
2332 PR_TRUE)); 2332 PR_TRUE));
2333 if (cert == NULL) 2333 if (cert == NULL)
2334 return MapNSSError(PORT_GetError()); 2334 return MapNSSError(PORT_GetError());
2335 2335
2336 crypto::ScopedPK11Slot slot(PK11_GetInternalSlot()); 2336 crypto::ScopedPK11Slot slot(PK11_GetInternalSlot());
2337 // Set the private key. 2337 // Set the private key.
2338 if (!crypto::ECPrivateKey::ImportFromEncryptedPrivateKeyInfo( 2338 if (!crypto::ECPrivateKey::ImportFromEncryptedPrivateKeyInfo(
2339 slot.get(), 2339 slot.get(),
2340 ServerBoundCertService::kEPKIPassword, 2340 ChannelIDService::kEPKIPassword,
2341 reinterpret_cast<const unsigned char*>( 2341 reinterpret_cast<const unsigned char*>(
2342 domain_bound_private_key_.data()), 2342 domain_bound_private_key_.data()),
2343 domain_bound_private_key_.size(), 2343 domain_bound_private_key_.size(),
2344 &cert->subjectPublicKeyInfo, 2344 &cert->subjectPublicKeyInfo,
2345 false, 2345 false,
2346 false, 2346 false,
2347 key, 2347 key,
2348 public_key)) { 2348 public_key)) {
2349 int error = MapNSSError(PORT_GetError()); 2349 int error = MapNSSError(PORT_GetError());
2350 return error; 2350 return error;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
2550 ssl_config_.channel_id_enabled, 2550 ssl_config_.channel_id_enabled,
2551 crypto::ECPrivateKey::IsSupported())); 2551 crypto::ECPrivateKey::IsSupported()));
2552 } 2552 }
2553 2553
2554 void SSLClientSocketNSS::Core::RecordChannelIDSupportOnNetworkTaskRunner( 2554 void SSLClientSocketNSS::Core::RecordChannelIDSupportOnNetworkTaskRunner(
2555 bool negotiated_channel_id, 2555 bool negotiated_channel_id,
2556 bool channel_id_enabled, 2556 bool channel_id_enabled,
2557 bool supports_ecc) const { 2557 bool supports_ecc) const {
2558 DCHECK(OnNetworkTaskRunner()); 2558 DCHECK(OnNetworkTaskRunner());
2559 2559
2560 RecordChannelIDSupport(server_bound_cert_service_, 2560 RecordChannelIDSupport(channel_id_service_,
2561 negotiated_channel_id, 2561 negotiated_channel_id,
2562 channel_id_enabled, 2562 channel_id_enabled,
2563 supports_ecc); 2563 supports_ecc);
2564 } 2564 }
2565 2565
2566 int SSLClientSocketNSS::Core::DoBufferRecv(IOBuffer* read_buffer, int len) { 2566 int SSLClientSocketNSS::Core::DoBufferRecv(IOBuffer* read_buffer, int len) {
2567 DCHECK(OnNetworkTaskRunner()); 2567 DCHECK(OnNetworkTaskRunner());
2568 DCHECK_GT(len, 0); 2568 DCHECK_GT(len, 0);
2569 2569
2570 if (detached_) 2570 if (detached_)
(...skipping 29 matching lines...) Expand all
2600 if (!OnNSSTaskRunner() && rv != ERR_IO_PENDING) { 2600 if (!OnNSSTaskRunner() && rv != ERR_IO_PENDING) {
2601 nss_task_runner_->PostTask( 2601 nss_task_runner_->PostTask(
2602 FROM_HERE, 2602 FROM_HERE,
2603 base::Bind(&Core::BufferSendComplete, this, rv)); 2603 base::Bind(&Core::BufferSendComplete, this, rv));
2604 return rv; 2604 return rv;
2605 } 2605 }
2606 2606
2607 return rv; 2607 return rv;
2608 } 2608 }
2609 2609
2610 int SSLClientSocketNSS::Core::DoGetDomainBoundCert(const std::string& host) { 2610 int SSLClientSocketNSS::Core::DoGetChannelID(const std::string& host) {
2611 DCHECK(OnNetworkTaskRunner()); 2611 DCHECK(OnNetworkTaskRunner());
2612 2612
2613 if (detached_) 2613 if (detached_)
2614 return ERR_ABORTED; 2614 return ERR_ABORTED;
2615 2615
2616 weak_net_log_->BeginEvent(NetLog::TYPE_SSL_GET_DOMAIN_BOUND_CERT); 2616 weak_net_log_->BeginEvent(NetLog::TYPE_SSL_GET_DOMAIN_BOUND_CERT);
2617 2617
2618 int rv = server_bound_cert_service_->GetOrCreateDomainBoundCert( 2618 int rv = channel_id_service_->GetOrCreateChannelID(
2619 host, 2619 host,
2620 &domain_bound_private_key_, 2620 &domain_bound_private_key_,
2621 &domain_bound_cert_, 2621 &domain_bound_cert_,
2622 base::Bind(&Core::OnGetDomainBoundCertComplete, base::Unretained(this)), 2622 base::Bind(&Core::OnGetChannelIDComplete, base::Unretained(this)),
2623 &domain_bound_cert_request_handle_); 2623 &domain_bound_cert_request_handle_);
2624 2624
2625 if (rv != ERR_IO_PENDING && !OnNSSTaskRunner()) { 2625 if (rv != ERR_IO_PENDING && !OnNSSTaskRunner()) {
2626 nss_task_runner_->PostTask( 2626 nss_task_runner_->PostTask(
2627 FROM_HERE, 2627 FROM_HERE,
2628 base::Bind(&Core::OnHandshakeIOComplete, this, rv)); 2628 base::Bind(&Core::OnHandshakeIOComplete, this, rv));
2629 return ERR_IO_PENDING; 2629 return ERR_IO_PENDING;
2630 } 2630 }
2631 2631
2632 return rv; 2632 return rv;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2692 return; 2692 return;
2693 } 2693 }
2694 2694
2695 DCHECK(OnNSSTaskRunner()); 2695 DCHECK(OnNSSTaskRunner());
2696 2696
2697 int rv = DoHandshakeLoop(result); 2697 int rv = DoHandshakeLoop(result);
2698 if (rv != ERR_IO_PENDING) 2698 if (rv != ERR_IO_PENDING)
2699 DoConnectCallback(rv); 2699 DoConnectCallback(rv);
2700 } 2700 }
2701 2701
2702 void SSLClientSocketNSS::Core::OnGetDomainBoundCertComplete(int result) { 2702 void SSLClientSocketNSS::Core::OnGetChannelIDComplete(int result) {
2703 DVLOG(1) << __FUNCTION__ << " " << result; 2703 DVLOG(1) << __FUNCTION__ << " " << result;
2704 DCHECK(OnNetworkTaskRunner()); 2704 DCHECK(OnNetworkTaskRunner());
2705 2705
2706 OnHandshakeIOComplete(result); 2706 OnHandshakeIOComplete(result);
2707 } 2707 }
2708 2708
2709 void SSLClientSocketNSS::Core::BufferRecvComplete( 2709 void SSLClientSocketNSS::Core::BufferRecvComplete(
2710 IOBuffer* read_buffer, 2710 IOBuffer* read_buffer,
2711 int result) { 2711 int result) {
2712 DCHECK(read_buffer); 2712 DCHECK(read_buffer);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2777 scoped_ptr<ClientSocketHandle> transport_socket, 2777 scoped_ptr<ClientSocketHandle> transport_socket,
2778 const HostPortPair& host_and_port, 2778 const HostPortPair& host_and_port,
2779 const SSLConfig& ssl_config, 2779 const SSLConfig& ssl_config,
2780 const SSLClientSocketContext& context) 2780 const SSLClientSocketContext& context)
2781 : nss_task_runner_(nss_task_runner), 2781 : nss_task_runner_(nss_task_runner),
2782 transport_(transport_socket.Pass()), 2782 transport_(transport_socket.Pass()),
2783 host_and_port_(host_and_port), 2783 host_and_port_(host_and_port),
2784 ssl_config_(ssl_config), 2784 ssl_config_(ssl_config),
2785 cert_verifier_(context.cert_verifier), 2785 cert_verifier_(context.cert_verifier),
2786 cert_transparency_verifier_(context.cert_transparency_verifier), 2786 cert_transparency_verifier_(context.cert_transparency_verifier),
2787 server_bound_cert_service_(context.server_bound_cert_service), 2787 channel_id_service_(context.channel_id_service),
2788 ssl_session_cache_shard_(context.ssl_session_cache_shard), 2788 ssl_session_cache_shard_(context.ssl_session_cache_shard),
2789 completed_handshake_(false), 2789 completed_handshake_(false),
2790 next_handshake_state_(STATE_NONE), 2790 next_handshake_state_(STATE_NONE),
2791 nss_fd_(NULL), 2791 nss_fd_(NULL),
2792 net_log_(transport_->socket()->NetLog()), 2792 net_log_(transport_->socket()->NetLog()),
2793 transport_security_state_(context.transport_security_state), 2793 transport_security_state_(context.transport_security_state),
2794 valid_thread_id_(base::kInvalidThreadId) { 2794 valid_thread_id_(base::kInvalidThreadId) {
2795 EnterFunction(""); 2795 EnterFunction("");
2796 InitCore(); 2796 InitCore();
2797 LeaveFunction(""); 2797 LeaveFunction("");
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
3088 return OK; 3088 return OK;
3089 } 3089 }
3090 3090
3091 void SSLClientSocketNSS::InitCore() { 3091 void SSLClientSocketNSS::InitCore() {
3092 core_ = new Core(base::ThreadTaskRunnerHandle::Get().get(), 3092 core_ = new Core(base::ThreadTaskRunnerHandle::Get().get(),
3093 nss_task_runner_.get(), 3093 nss_task_runner_.get(),
3094 transport_.get(), 3094 transport_.get(),
3095 host_and_port_, 3095 host_and_port_,
3096 ssl_config_, 3096 ssl_config_,
3097 &net_log_, 3097 &net_log_,
3098 server_bound_cert_service_); 3098 channel_id_service_);
3099 } 3099 }
3100 3100
3101 int SSLClientSocketNSS::InitializeSSLOptions() { 3101 int SSLClientSocketNSS::InitializeSSLOptions() {
3102 // Transport connected, now hook it up to nss 3102 // Transport connected, now hook it up to nss
3103 nss_fd_ = memio_CreateIOLayer(kRecvBufferSize, kSendBufferSize); 3103 nss_fd_ = memio_CreateIOLayer(kRecvBufferSize, kSendBufferSize);
3104 if (nss_fd_ == NULL) { 3104 if (nss_fd_ == NULL) {
3105 return ERR_OUT_OF_MEMORY; // TODO(port): map NSPR error code. 3105 return ERR_OUT_OF_MEMORY; // TODO(port): map NSPR error code.
3106 } 3106 }
3107 3107
3108 // Grab pointer to buffers 3108 // Grab pointer to buffers
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
3584 SignedCertificateTimestampAndStatus(*iter, 3584 SignedCertificateTimestampAndStatus(*iter,
3585 ct::SCT_STATUS_LOG_UNKNOWN)); 3585 ct::SCT_STATUS_LOG_UNKNOWN));
3586 } 3586 }
3587 } 3587 }
3588 3588
3589 scoped_refptr<X509Certificate> 3589 scoped_refptr<X509Certificate>
3590 SSLClientSocketNSS::GetUnverifiedServerCertificateChain() const { 3590 SSLClientSocketNSS::GetUnverifiedServerCertificateChain() const {
3591 return core_->state().server_cert.get(); 3591 return core_->state().server_cert.get();
3592 } 3592 }
3593 3593
3594 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const { 3594 ChannelIDService* SSLClientSocketNSS::GetChannelIDService() const {
3595 return server_bound_cert_service_; 3595 return channel_id_service_;
3596 } 3596 }
3597 3597
3598 } // namespace net 3598 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698