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 // 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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 // | 517 // |
518 // In the single-threaded mode (where the network and NSS task runners run on | 518 // In the single-threaded mode (where the network and NSS task runners run on |
519 // the same thread), these are all attempted synchronously, while in the | 519 // the same thread), these are all attempted synchronously, while in the |
520 // multi-threaded mode, message passing is used. | 520 // multi-threaded mode, message passing is used. |
521 // | 521 // |
522 // 1) NSS Task Runner: Execute NSS function (DoPayloadRead, DoPayloadWrite, | 522 // 1) NSS Task Runner: Execute NSS function (DoPayloadRead, DoPayloadWrite, |
523 // DoHandshake) | 523 // DoHandshake) |
524 // 2) NSS Task Runner: Prepare data to go from NSS to an IO function: | 524 // 2) NSS Task Runner: Prepare data to go from NSS to an IO function: |
525 // (BufferRecv, BufferSend) | 525 // (BufferRecv, BufferSend) |
526 // 3) Network Task Runner: Perform IO on that data (DoBufferRecv, | 526 // 3) Network Task Runner: Perform IO on that data (DoBufferRecv, |
527 // DoBufferSend, DoGetDomainBoundCert, OnGetDomainBoundCertComplete) | 527 // DoBufferSend, DoGetChannelID, OnGetDomainBoundCertComplete) |
wtc
2014/07/01 19:50:53
OnGetDomainBoundCertComplete => OnGetChannelIDComp
Ryan Hamilton
2014/07/21 19:12:09
Done.
| |
528 // 4) Both Task Runners: Callback for asynchronous completion or to marshal | 528 // 4) Both Task Runners: Callback for asynchronous completion or to marshal |
529 // data from the network task runner back to NSS (BufferRecvComplete, | 529 // data from the network task runner back to NSS (BufferRecvComplete, |
530 // BufferSendComplete, OnHandshakeIOComplete) | 530 // BufferSendComplete, OnHandshakeIOComplete) |
531 // | 531 // |
532 ///////////////////////////////////////////////////////////////////////////// | 532 ///////////////////////////////////////////////////////////////////////////// |
533 // Single-threaded example | 533 // Single-threaded example |
534 // | 534 // |
535 // |--------------------------Network Task Runner--------------------------| | 535 // |--------------------------Network Task Runner--------------------------| |
536 // SSLClientSocketNSS Core (Transport Socket) | 536 // SSLClientSocketNSS Core (Transport Socket) |
537 // Read() | 537 // Read() |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
585 class SSLClientSocketNSS::Core : public base::RefCountedThreadSafe<Core> { | 585 class SSLClientSocketNSS::Core : public base::RefCountedThreadSafe<Core> { |
586 public: | 586 public: |
587 // Creates a new Core. | 587 // Creates a new Core. |
588 // | 588 // |
589 // Any calls to NSS are executed on the |nss_task_runner|, while any calls | 589 // Any calls to NSS are executed on the |nss_task_runner|, while any calls |
590 // that need to operate on the underlying transport, net log, or server | 590 // that need to operate on the underlying transport, net log, or server |
591 // bound certificate fetching will happen on the |network_task_runner|, so | 591 // bound certificate fetching will happen on the |network_task_runner|, so |
592 // that their lifetimes match that of the owning SSLClientSocketNSS. | 592 // that their lifetimes match that of the owning SSLClientSocketNSS. |
593 // | 593 // |
594 // The caller retains ownership of |transport|, |net_log|, and | 594 // The caller retains ownership of |transport|, |net_log|, and |
595 // |server_bound_cert_service|, and they will not be accessed once Detach() | 595 // |channel_id_service|, and they will not be accessed once Detach() |
596 // has been called. | 596 // has been called. |
597 Core(base::SequencedTaskRunner* network_task_runner, | 597 Core(base::SequencedTaskRunner* network_task_runner, |
598 base::SequencedTaskRunner* nss_task_runner, | 598 base::SequencedTaskRunner* nss_task_runner, |
599 ClientSocketHandle* transport, | 599 ClientSocketHandle* transport, |
600 const HostPortPair& host_and_port, | 600 const HostPortPair& host_and_port, |
601 const SSLConfig& ssl_config, | 601 const SSLConfig& ssl_config, |
602 BoundNetLog* net_log, | 602 BoundNetLog* net_log, |
603 ServerBoundCertService* server_bound_cert_service); | 603 ChannelIDService* channel_id_service); |
604 | 604 |
605 // Called on the network task runner. | 605 // Called on the network task runner. |
606 // Transfers ownership of |socket|, an NSS SSL socket, and |buffers|, the | 606 // Transfers ownership of |socket|, an NSS SSL socket, and |buffers|, the |
607 // underlying memio implementation, to the Core. Returns true if the Core | 607 // underlying memio implementation, to the Core. Returns true if the Core |
608 // was successfully registered with the socket. | 608 // was successfully registered with the socket. |
609 bool Init(PRFileDesc* socket, memio_Private* buffers); | 609 bool Init(PRFileDesc* socket, memio_Private* buffers); |
610 | 610 |
611 // Called on the network task runner. | 611 // Called on the network task runner. |
612 // | 612 // |
613 // Attempts to perform an SSL handshake. If the handshake cannot be | 613 // Attempts to perform an SSL handshake. If the handshake cannot be |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
747 static SECStatus ClientChannelIDHandler( | 747 static SECStatus ClientChannelIDHandler( |
748 void* arg, | 748 void* arg, |
749 PRFileDesc* socket, | 749 PRFileDesc* socket, |
750 SECKEYPublicKey **out_public_key, | 750 SECKEYPublicKey **out_public_key, |
751 SECKEYPrivateKey **out_private_key); | 751 SECKEYPrivateKey **out_private_key); |
752 | 752 |
753 // ImportChannelIDKeys is a helper function for turning a DER-encoded cert and | 753 // ImportChannelIDKeys is a helper function for turning a DER-encoded cert and |
754 // key into a SECKEYPublicKey and SECKEYPrivateKey. Returns OK upon success | 754 // key into a SECKEYPublicKey and SECKEYPrivateKey. Returns OK upon success |
755 // and an error code otherwise. | 755 // and an error code otherwise. |
756 // Requires |domain_bound_private_key_| and |domain_bound_cert_| to have been | 756 // Requires |domain_bound_private_key_| and |domain_bound_cert_| to have been |
757 // set by a call to ServerBoundCertService->GetDomainBoundCert. The caller | 757 // set by a call to ChannelIDService->GetChannelID. The caller |
758 // takes ownership of the |*cert| and |*key|. | 758 // takes ownership of the |*cert| and |*key|. |
759 int ImportChannelIDKeys(SECKEYPublicKey** public_key, SECKEYPrivateKey** key); | 759 int ImportChannelIDKeys(SECKEYPublicKey** public_key, SECKEYPrivateKey** key); |
760 | 760 |
761 // Updates the NSS and platform specific certificates. | 761 // Updates the NSS and platform specific certificates. |
762 void UpdateServerCert(); | 762 void UpdateServerCert(); |
763 // Update the nss_handshake_state_ with the SignedCertificateTimestampList | 763 // Update the nss_handshake_state_ with the SignedCertificateTimestampList |
764 // received in the handshake via a TLS extension. | 764 // received in the handshake via a TLS extension. |
765 void UpdateSignedCertTimestamps(); | 765 void UpdateSignedCertTimestamps(); |
766 // Update the OCSP response cache with the stapled response received in the | 766 // Update the OCSP response cache with the stapled response received in the |
767 // handshake, and update nss_handshake_state_ with | 767 // handshake, and update nss_handshake_state_ with |
768 // the SignedCertificateTimestampList received in the stapled OCSP response. | 768 // the SignedCertificateTimestampList received in the stapled OCSP response. |
769 void UpdateStapledOCSPResponse(); | 769 void UpdateStapledOCSPResponse(); |
770 // Updates the nss_handshake_state_ with the negotiated security parameters. | 770 // Updates the nss_handshake_state_ with the negotiated security parameters. |
771 void UpdateConnectionStatus(); | 771 void UpdateConnectionStatus(); |
772 // Record histograms for channel id support during full handshakes - resumed | 772 // Record histograms for channel id support during full handshakes - resumed |
773 // handshakes are ignored. | 773 // handshakes are ignored. |
774 void RecordChannelIDSupportOnNSSTaskRunner(); | 774 void RecordChannelIDSupportOnNSSTaskRunner(); |
775 // UpdateNextProto gets any application-layer protocol that may have been | 775 // UpdateNextProto gets any application-layer protocol that may have been |
776 // negotiated by the TLS connection. | 776 // negotiated by the TLS connection. |
777 void UpdateNextProto(); | 777 void UpdateNextProto(); |
778 | 778 |
779 //////////////////////////////////////////////////////////////////////////// | 779 //////////////////////////////////////////////////////////////////////////// |
780 // Methods that are ONLY called on the network task runner: | 780 // Methods that are ONLY called on the network task runner: |
781 //////////////////////////////////////////////////////////////////////////// | 781 //////////////////////////////////////////////////////////////////////////// |
782 int DoBufferRecv(IOBuffer* buffer, int len); | 782 int DoBufferRecv(IOBuffer* buffer, int len); |
783 int DoBufferSend(IOBuffer* buffer, int len); | 783 int DoBufferSend(IOBuffer* buffer, int len); |
784 int DoGetDomainBoundCert(const std::string& host); | 784 int DoGetChannelID(const std::string& host); |
785 | 785 |
786 void OnGetDomainBoundCertComplete(int result); | 786 void OnGetChannelIDComplete(int result); |
787 void OnHandshakeStateUpdated(const HandshakeState& state); | 787 void OnHandshakeStateUpdated(const HandshakeState& state); |
788 void OnNSSBufferUpdated(int amount_in_read_buffer); | 788 void OnNSSBufferUpdated(int amount_in_read_buffer); |
789 void DidNSSRead(int result); | 789 void DidNSSRead(int result); |
790 void DidNSSWrite(int result); | 790 void DidNSSWrite(int result); |
791 void RecordChannelIDSupportOnNetworkTaskRunner( | 791 void RecordChannelIDSupportOnNetworkTaskRunner( |
792 bool negotiated_channel_id, | 792 bool negotiated_channel_id, |
793 bool channel_id_enabled, | 793 bool channel_id_enabled, |
794 bool supports_ecc) const; | 794 bool supports_ecc) const; |
795 | 795 |
796 //////////////////////////////////////////////////////////////////////////// | 796 //////////////////////////////////////////////////////////////////////////// |
(...skipping 28 matching lines...) Expand all Loading... | |
825 bool detached_; | 825 bool detached_; |
826 | 826 |
827 // The underlying transport to use for network IO. | 827 // The underlying transport to use for network IO. |
828 ClientSocketHandle* transport_; | 828 ClientSocketHandle* transport_; |
829 base::WeakPtrFactory<BoundNetLog> weak_net_log_factory_; | 829 base::WeakPtrFactory<BoundNetLog> weak_net_log_factory_; |
830 | 830 |
831 // The current handshake state. Mirrors |nss_handshake_state_|. | 831 // The current handshake state. Mirrors |nss_handshake_state_|. |
832 HandshakeState network_handshake_state_; | 832 HandshakeState network_handshake_state_; |
833 | 833 |
834 // The service for retrieving Channel ID keys. May be NULL. | 834 // The service for retrieving Channel ID keys. May be NULL. |
835 ServerBoundCertService* server_bound_cert_service_; | 835 ChannelIDService* channel_id_service_; |
836 ServerBoundCertService::RequestHandle domain_bound_cert_request_handle_; | 836 ChannelIDService::RequestHandle domain_bound_cert_request_handle_; |
837 | 837 |
838 // The information about NSS task runner. | 838 // The information about NSS task runner. |
839 int unhandled_buffer_size_; | 839 int unhandled_buffer_size_; |
840 bool nss_waiting_read_; | 840 bool nss_waiting_read_; |
841 bool nss_waiting_write_; | 841 bool nss_waiting_write_; |
842 bool nss_is_closed_; | 842 bool nss_is_closed_; |
843 | 843 |
844 // Set when Read() or Write() successfully reads or writes data to or from the | 844 // Set when Read() or Write() successfully reads or writes data to or from the |
845 // network. | 845 // network. |
846 bool was_ever_used_; | 846 bool was_ever_used_; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
907 // Members that are accessed on both the network task runner and the NSS | 907 // Members that are accessed on both the network task runner and the NSS |
908 // task runner. | 908 // task runner. |
909 //////////////////////////////////////////////////////////////////////////// | 909 //////////////////////////////////////////////////////////////////////////// |
910 scoped_refptr<base::SequencedTaskRunner> network_task_runner_; | 910 scoped_refptr<base::SequencedTaskRunner> network_task_runner_; |
911 scoped_refptr<base::SequencedTaskRunner> nss_task_runner_; | 911 scoped_refptr<base::SequencedTaskRunner> nss_task_runner_; |
912 | 912 |
913 // Dereferenced only on the network task runner, but bound to tasks destined | 913 // Dereferenced only on the network task runner, but bound to tasks destined |
914 // for the network task runner from the NSS task runner. | 914 // for the network task runner from the NSS task runner. |
915 base::WeakPtr<BoundNetLog> weak_net_log_; | 915 base::WeakPtr<BoundNetLog> weak_net_log_; |
916 | 916 |
917 // Written on the network task runner by the |server_bound_cert_service_|, | 917 // Written on the network task runner by the |channel_id_service_|, |
918 // prior to invoking OnHandshakeIOComplete. | 918 // prior to invoking OnHandshakeIOComplete. |
919 // Read on the NSS task runner when once OnHandshakeIOComplete is invoked | 919 // Read on the NSS task runner when once OnHandshakeIOComplete is invoked |
920 // on the NSS task runner. | 920 // on the NSS task runner. |
921 std::string domain_bound_private_key_; | 921 std::string domain_bound_private_key_; |
922 std::string domain_bound_cert_; | 922 std::string domain_bound_cert_; |
923 | 923 |
924 DISALLOW_COPY_AND_ASSIGN(Core); | 924 DISALLOW_COPY_AND_ASSIGN(Core); |
925 }; | 925 }; |
926 | 926 |
927 SSLClientSocketNSS::Core::Core( | 927 SSLClientSocketNSS::Core::Core( |
928 base::SequencedTaskRunner* network_task_runner, | 928 base::SequencedTaskRunner* network_task_runner, |
929 base::SequencedTaskRunner* nss_task_runner, | 929 base::SequencedTaskRunner* nss_task_runner, |
930 ClientSocketHandle* transport, | 930 ClientSocketHandle* transport, |
931 const HostPortPair& host_and_port, | 931 const HostPortPair& host_and_port, |
932 const SSLConfig& ssl_config, | 932 const SSLConfig& ssl_config, |
933 BoundNetLog* net_log, | 933 BoundNetLog* net_log, |
934 ServerBoundCertService* server_bound_cert_service) | 934 ChannelIDService* channel_id_service) |
935 : detached_(false), | 935 : detached_(false), |
936 transport_(transport), | 936 transport_(transport), |
937 weak_net_log_factory_(net_log), | 937 weak_net_log_factory_(net_log), |
938 server_bound_cert_service_(server_bound_cert_service), | 938 channel_id_service_(channel_id_service), |
939 unhandled_buffer_size_(0), | 939 unhandled_buffer_size_(0), |
940 nss_waiting_read_(false), | 940 nss_waiting_read_(false), |
941 nss_waiting_write_(false), | 941 nss_waiting_write_(false), |
942 nss_is_closed_(false), | 942 nss_is_closed_(false), |
943 was_ever_used_(false), | 943 was_ever_used_(false), |
944 host_and_port_(host_and_port), | 944 host_and_port_(host_and_port), |
945 ssl_config_(ssl_config), | 945 ssl_config_(ssl_config), |
946 nss_fd_(NULL), | 946 nss_fd_(NULL), |
947 nss_bufs_(NULL), | 947 nss_bufs_(NULL), |
948 pending_read_result_(kNoPendingReadResult), | 948 pending_read_result_(kNoPendingReadResult), |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1031 this); | 1031 this); |
1032 #else | 1032 #else |
1033 rv = SSL_GetClientAuthDataHook( | 1033 rv = SSL_GetClientAuthDataHook( |
1034 nss_fd_, SSLClientSocketNSS::Core::ClientAuthHandler, this); | 1034 nss_fd_, SSLClientSocketNSS::Core::ClientAuthHandler, this); |
1035 #endif | 1035 #endif |
1036 if (rv != SECSuccess) { | 1036 if (rv != SECSuccess) { |
1037 LogFailedNSSFunction(*weak_net_log_, "SSL_GetClientAuthDataHook", ""); | 1037 LogFailedNSSFunction(*weak_net_log_, "SSL_GetClientAuthDataHook", ""); |
1038 return false; | 1038 return false; |
1039 } | 1039 } |
1040 | 1040 |
1041 if (IsChannelIDEnabled(ssl_config_, server_bound_cert_service_)) { | 1041 if (IsChannelIDEnabled(ssl_config_, channel_id_service_)) { |
1042 rv = SSL_SetClientChannelIDCallback( | 1042 rv = SSL_SetClientChannelIDCallback( |
1043 nss_fd_, SSLClientSocketNSS::Core::ClientChannelIDHandler, this); | 1043 nss_fd_, SSLClientSocketNSS::Core::ClientChannelIDHandler, this); |
1044 if (rv != SECSuccess) { | 1044 if (rv != SECSuccess) { |
1045 LogFailedNSSFunction( | 1045 LogFailedNSSFunction( |
1046 *weak_net_log_, "SSL_SetClientChannelIDCallback", ""); | 1046 *weak_net_log_, "SSL_SetClientChannelIDCallback", ""); |
1047 } | 1047 } |
1048 } | 1048 } |
1049 | 1049 |
1050 rv = SSL_SetCanFalseStartCallback( | 1050 rv = SSL_SetCanFalseStartCallback( |
1051 nss_fd_, SSLClientSocketNSS::Core::CanFalseStartCallback, this); | 1051 nss_fd_, SSLClientSocketNSS::Core::CanFalseStartCallback, this); |
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2308 core->PostOrRunCallback( | 2308 core->PostOrRunCallback( |
2309 FROM_HERE, | 2309 FROM_HERE, |
2310 base::Bind(&AddLogEvent, core->weak_net_log_, | 2310 base::Bind(&AddLogEvent, core->weak_net_log_, |
2311 NetLog::TYPE_SSL_CHANNEL_ID_REQUESTED)); | 2311 NetLog::TYPE_SSL_CHANNEL_ID_REQUESTED)); |
2312 | 2312 |
2313 // We have negotiated the TLS channel ID extension. | 2313 // We have negotiated the TLS channel ID extension. |
2314 core->channel_id_xtn_negotiated_ = true; | 2314 core->channel_id_xtn_negotiated_ = true; |
2315 std::string host = core->host_and_port_.host(); | 2315 std::string host = core->host_and_port_.host(); |
2316 int error = ERR_UNEXPECTED; | 2316 int error = ERR_UNEXPECTED; |
2317 if (core->OnNetworkTaskRunner()) { | 2317 if (core->OnNetworkTaskRunner()) { |
2318 error = core->DoGetDomainBoundCert(host); | 2318 error = core->DoGetChannelID(host); |
2319 } else { | 2319 } else { |
2320 bool posted = core->network_task_runner_->PostTask( | 2320 bool posted = core->network_task_runner_->PostTask( |
2321 FROM_HERE, | 2321 FROM_HERE, |
2322 base::Bind( | 2322 base::Bind( |
2323 IgnoreResult(&Core::DoGetDomainBoundCert), | 2323 IgnoreResult(&Core::DoGetChannelID), |
2324 core, host)); | 2324 core, host)); |
2325 error = posted ? ERR_IO_PENDING : ERR_ABORTED; | 2325 error = posted ? ERR_IO_PENDING : ERR_ABORTED; |
2326 } | 2326 } |
2327 | 2327 |
2328 if (error == ERR_IO_PENDING) { | 2328 if (error == ERR_IO_PENDING) { |
2329 // Asynchronous case. | 2329 // Asynchronous case. |
2330 core->channel_id_needed_ = true; | 2330 core->channel_id_needed_ = true; |
2331 return SECWouldBlock; | 2331 return SECWouldBlock; |
2332 } | 2332 } |
2333 | 2333 |
(...skipping 27 matching lines...) Expand all Loading... | |
2361 NULL, | 2361 NULL, |
2362 PR_FALSE, | 2362 PR_FALSE, |
2363 PR_TRUE)); | 2363 PR_TRUE)); |
2364 if (cert == NULL) | 2364 if (cert == NULL) |
2365 return MapNSSError(PORT_GetError()); | 2365 return MapNSSError(PORT_GetError()); |
2366 | 2366 |
2367 crypto::ScopedPK11Slot slot(PK11_GetInternalSlot()); | 2367 crypto::ScopedPK11Slot slot(PK11_GetInternalSlot()); |
2368 // Set the private key. | 2368 // Set the private key. |
2369 if (!crypto::ECPrivateKey::ImportFromEncryptedPrivateKeyInfo( | 2369 if (!crypto::ECPrivateKey::ImportFromEncryptedPrivateKeyInfo( |
2370 slot.get(), | 2370 slot.get(), |
2371 ServerBoundCertService::kEPKIPassword, | 2371 ChannelIDService::kEPKIPassword, |
2372 reinterpret_cast<const unsigned char*>( | 2372 reinterpret_cast<const unsigned char*>( |
2373 domain_bound_private_key_.data()), | 2373 domain_bound_private_key_.data()), |
2374 domain_bound_private_key_.size(), | 2374 domain_bound_private_key_.size(), |
2375 &cert->subjectPublicKeyInfo, | 2375 &cert->subjectPublicKeyInfo, |
2376 false, | 2376 false, |
2377 false, | 2377 false, |
2378 key, | 2378 key, |
2379 public_key)) { | 2379 public_key)) { |
2380 int error = MapNSSError(PORT_GetError()); | 2380 int error = MapNSSError(PORT_GetError()); |
2381 return error; | 2381 return error; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2581 ssl_config_.channel_id_enabled, | 2581 ssl_config_.channel_id_enabled, |
2582 crypto::ECPrivateKey::IsSupported())); | 2582 crypto::ECPrivateKey::IsSupported())); |
2583 } | 2583 } |
2584 | 2584 |
2585 void SSLClientSocketNSS::Core::RecordChannelIDSupportOnNetworkTaskRunner( | 2585 void SSLClientSocketNSS::Core::RecordChannelIDSupportOnNetworkTaskRunner( |
2586 bool negotiated_channel_id, | 2586 bool negotiated_channel_id, |
2587 bool channel_id_enabled, | 2587 bool channel_id_enabled, |
2588 bool supports_ecc) const { | 2588 bool supports_ecc) const { |
2589 DCHECK(OnNetworkTaskRunner()); | 2589 DCHECK(OnNetworkTaskRunner()); |
2590 | 2590 |
2591 RecordChannelIDSupport(server_bound_cert_service_, | 2591 RecordChannelIDSupport(channel_id_service_, |
2592 negotiated_channel_id, | 2592 negotiated_channel_id, |
2593 channel_id_enabled, | 2593 channel_id_enabled, |
2594 supports_ecc); | 2594 supports_ecc); |
2595 } | 2595 } |
2596 | 2596 |
2597 int SSLClientSocketNSS::Core::DoBufferRecv(IOBuffer* read_buffer, int len) { | 2597 int SSLClientSocketNSS::Core::DoBufferRecv(IOBuffer* read_buffer, int len) { |
2598 DCHECK(OnNetworkTaskRunner()); | 2598 DCHECK(OnNetworkTaskRunner()); |
2599 DCHECK_GT(len, 0); | 2599 DCHECK_GT(len, 0); |
2600 | 2600 |
2601 if (detached_) | 2601 if (detached_) |
(...skipping 29 matching lines...) Expand all Loading... | |
2631 if (!OnNSSTaskRunner() && rv != ERR_IO_PENDING) { | 2631 if (!OnNSSTaskRunner() && rv != ERR_IO_PENDING) { |
2632 nss_task_runner_->PostTask( | 2632 nss_task_runner_->PostTask( |
2633 FROM_HERE, | 2633 FROM_HERE, |
2634 base::Bind(&Core::BufferSendComplete, this, rv)); | 2634 base::Bind(&Core::BufferSendComplete, this, rv)); |
2635 return rv; | 2635 return rv; |
2636 } | 2636 } |
2637 | 2637 |
2638 return rv; | 2638 return rv; |
2639 } | 2639 } |
2640 | 2640 |
2641 int SSLClientSocketNSS::Core::DoGetDomainBoundCert(const std::string& host) { | 2641 int SSLClientSocketNSS::Core::DoGetChannelID(const std::string& host) { |
2642 DCHECK(OnNetworkTaskRunner()); | 2642 DCHECK(OnNetworkTaskRunner()); |
2643 | 2643 |
2644 if (detached_) | 2644 if (detached_) |
2645 return ERR_ABORTED; | 2645 return ERR_ABORTED; |
2646 | 2646 |
2647 weak_net_log_->BeginEvent(NetLog::TYPE_SSL_GET_DOMAIN_BOUND_CERT); | 2647 weak_net_log_->BeginEvent(NetLog::TYPE_SSL_GET_DOMAIN_BOUND_CERT); |
2648 | 2648 |
2649 int rv = server_bound_cert_service_->GetOrCreateDomainBoundCert( | 2649 int rv = channel_id_service_->GetOrCreateChannelID( |
2650 host, | 2650 host, |
2651 &domain_bound_private_key_, | 2651 &domain_bound_private_key_, |
2652 &domain_bound_cert_, | 2652 &domain_bound_cert_, |
2653 base::Bind(&Core::OnGetDomainBoundCertComplete, base::Unretained(this)), | 2653 base::Bind(&Core::OnGetChannelIDComplete, base::Unretained(this)), |
2654 &domain_bound_cert_request_handle_); | 2654 &domain_bound_cert_request_handle_); |
2655 | 2655 |
2656 if (rv != ERR_IO_PENDING && !OnNSSTaskRunner()) { | 2656 if (rv != ERR_IO_PENDING && !OnNSSTaskRunner()) { |
2657 nss_task_runner_->PostTask( | 2657 nss_task_runner_->PostTask( |
2658 FROM_HERE, | 2658 FROM_HERE, |
2659 base::Bind(&Core::OnHandshakeIOComplete, this, rv)); | 2659 base::Bind(&Core::OnHandshakeIOComplete, this, rv)); |
2660 return ERR_IO_PENDING; | 2660 return ERR_IO_PENDING; |
2661 } | 2661 } |
2662 | 2662 |
2663 return rv; | 2663 return rv; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2723 return; | 2723 return; |
2724 } | 2724 } |
2725 | 2725 |
2726 DCHECK(OnNSSTaskRunner()); | 2726 DCHECK(OnNSSTaskRunner()); |
2727 | 2727 |
2728 int rv = DoHandshakeLoop(result); | 2728 int rv = DoHandshakeLoop(result); |
2729 if (rv != ERR_IO_PENDING) | 2729 if (rv != ERR_IO_PENDING) |
2730 DoConnectCallback(rv); | 2730 DoConnectCallback(rv); |
2731 } | 2731 } |
2732 | 2732 |
2733 void SSLClientSocketNSS::Core::OnGetDomainBoundCertComplete(int result) { | 2733 void SSLClientSocketNSS::Core::OnGetChannelIDComplete(int result) { |
2734 DVLOG(1) << __FUNCTION__ << " " << result; | 2734 DVLOG(1) << __FUNCTION__ << " " << result; |
2735 DCHECK(OnNetworkTaskRunner()); | 2735 DCHECK(OnNetworkTaskRunner()); |
2736 | 2736 |
2737 OnHandshakeIOComplete(result); | 2737 OnHandshakeIOComplete(result); |
2738 } | 2738 } |
2739 | 2739 |
2740 void SSLClientSocketNSS::Core::BufferRecvComplete( | 2740 void SSLClientSocketNSS::Core::BufferRecvComplete( |
2741 IOBuffer* read_buffer, | 2741 IOBuffer* read_buffer, |
2742 int result) { | 2742 int result) { |
2743 DCHECK(read_buffer); | 2743 DCHECK(read_buffer); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2808 scoped_ptr<ClientSocketHandle> transport_socket, | 2808 scoped_ptr<ClientSocketHandle> transport_socket, |
2809 const HostPortPair& host_and_port, | 2809 const HostPortPair& host_and_port, |
2810 const SSLConfig& ssl_config, | 2810 const SSLConfig& ssl_config, |
2811 const SSLClientSocketContext& context) | 2811 const SSLClientSocketContext& context) |
2812 : nss_task_runner_(nss_task_runner), | 2812 : nss_task_runner_(nss_task_runner), |
2813 transport_(transport_socket.Pass()), | 2813 transport_(transport_socket.Pass()), |
2814 host_and_port_(host_and_port), | 2814 host_and_port_(host_and_port), |
2815 ssl_config_(ssl_config), | 2815 ssl_config_(ssl_config), |
2816 cert_verifier_(context.cert_verifier), | 2816 cert_verifier_(context.cert_verifier), |
2817 cert_transparency_verifier_(context.cert_transparency_verifier), | 2817 cert_transparency_verifier_(context.cert_transparency_verifier), |
2818 server_bound_cert_service_(context.server_bound_cert_service), | 2818 channel_id_service_(context.channel_id_service), |
2819 ssl_session_cache_shard_(context.ssl_session_cache_shard), | 2819 ssl_session_cache_shard_(context.ssl_session_cache_shard), |
2820 completed_handshake_(false), | 2820 completed_handshake_(false), |
2821 next_handshake_state_(STATE_NONE), | 2821 next_handshake_state_(STATE_NONE), |
2822 nss_fd_(NULL), | 2822 nss_fd_(NULL), |
2823 net_log_(transport_->socket()->NetLog()), | 2823 net_log_(transport_->socket()->NetLog()), |
2824 transport_security_state_(context.transport_security_state), | 2824 transport_security_state_(context.transport_security_state), |
2825 valid_thread_id_(base::kInvalidThreadId) { | 2825 valid_thread_id_(base::kInvalidThreadId) { |
2826 EnterFunction(""); | 2826 EnterFunction(""); |
2827 InitCore(); | 2827 InitCore(); |
2828 LeaveFunction(""); | 2828 LeaveFunction(""); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3119 return OK; | 3119 return OK; |
3120 } | 3120 } |
3121 | 3121 |
3122 void SSLClientSocketNSS::InitCore() { | 3122 void SSLClientSocketNSS::InitCore() { |
3123 core_ = new Core(base::ThreadTaskRunnerHandle::Get().get(), | 3123 core_ = new Core(base::ThreadTaskRunnerHandle::Get().get(), |
3124 nss_task_runner_.get(), | 3124 nss_task_runner_.get(), |
3125 transport_.get(), | 3125 transport_.get(), |
3126 host_and_port_, | 3126 host_and_port_, |
3127 ssl_config_, | 3127 ssl_config_, |
3128 &net_log_, | 3128 &net_log_, |
3129 server_bound_cert_service_); | 3129 channel_id_service_); |
3130 } | 3130 } |
3131 | 3131 |
3132 int SSLClientSocketNSS::InitializeSSLOptions() { | 3132 int SSLClientSocketNSS::InitializeSSLOptions() { |
3133 // Transport connected, now hook it up to nss | 3133 // Transport connected, now hook it up to nss |
3134 nss_fd_ = memio_CreateIOLayer(kRecvBufferSize, kSendBufferSize); | 3134 nss_fd_ = memio_CreateIOLayer(kRecvBufferSize, kSendBufferSize); |
3135 if (nss_fd_ == NULL) { | 3135 if (nss_fd_ == NULL) { |
3136 return ERR_OUT_OF_MEMORY; // TODO(port): map NSPR error code. | 3136 return ERR_OUT_OF_MEMORY; // TODO(port): map NSPR error code. |
3137 } | 3137 } |
3138 | 3138 |
3139 // Grab pointer to buffers | 3139 // Grab pointer to buffers |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3615 SignedCertificateTimestampAndStatus(*iter, | 3615 SignedCertificateTimestampAndStatus(*iter, |
3616 ct::SCT_STATUS_LOG_UNKNOWN)); | 3616 ct::SCT_STATUS_LOG_UNKNOWN)); |
3617 } | 3617 } |
3618 } | 3618 } |
3619 | 3619 |
3620 scoped_refptr<X509Certificate> | 3620 scoped_refptr<X509Certificate> |
3621 SSLClientSocketNSS::GetUnverifiedServerCertificateChain() const { | 3621 SSLClientSocketNSS::GetUnverifiedServerCertificateChain() const { |
3622 return core_->state().server_cert.get(); | 3622 return core_->state().server_cert.get(); |
3623 } | 3623 } |
3624 | 3624 |
3625 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const { | 3625 ChannelIDService* SSLClientSocketNSS::GetChannelIDService() const { |
3626 return server_bound_cert_service_; | 3626 return channel_id_service_; |
3627 } | 3627 } |
3628 | 3628 |
3629 } // namespace net | 3629 } // namespace net |
OLD | NEW |