| 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 #ifndef NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ | 5 #ifndef NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ |
| 6 #define NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ | 6 #define NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ |
| 7 | 7 |
| 8 #include <certt.h> | 8 #include <certt.h> |
| 9 #include <keyt.h> | 9 #include <keyt.h> |
| 10 #include <nspr.h> | 10 #include <nspr.h> |
| 11 #include <nss.h> | 11 #include <nss.h> |
| 12 | 12 |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 18 #include "base/threading/platform_thread.h" | 18 #include "base/threading/platform_thread.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "base/timer/timer.h" | 20 #include "base/timer/timer.h" |
| 21 #include "net/base/completion_callback.h" | 21 #include "net/base/completion_callback.h" |
| 22 #include "net/base/host_port_pair.h" | 22 #include "net/base/host_port_pair.h" |
| 23 #include "net/base/net_export.h" | 23 #include "net/base/net_export.h" |
| 24 #include "net/base/net_log.h" | 24 #include "net/base/net_log.h" |
| 25 #include "net/base/nss_memio.h" | 25 #include "net/base/nss_memio.h" |
| 26 #include "net/cert/cert_verify_result.h" | 26 #include "net/cert/cert_verify_result.h" |
| 27 #include "net/cert/ct_verify_result.h" | 27 #include "net/cert/ct_verify_result.h" |
| 28 #include "net/cert/x509_certificate.h" | 28 #include "net/cert/x509_certificate.h" |
| 29 #include "net/socket/ssl_client_socket.h" | 29 #include "net/socket/ssl_client_socket.h" |
| 30 #include "net/ssl/server_bound_cert_service.h" | 30 #include "net/ssl/channel_id_service.h" |
| 31 #include "net/ssl/ssl_config_service.h" | 31 #include "net/ssl/ssl_config_service.h" |
| 32 | 32 |
| 33 namespace base { | 33 namespace base { |
| 34 class SequencedTaskRunner; | 34 class SequencedTaskRunner; |
| 35 } | 35 } |
| 36 | 36 |
| 37 namespace net { | 37 namespace net { |
| 38 | 38 |
| 39 class BoundNetLog; | 39 class BoundNetLog; |
| 40 class CertVerifier; | 40 class CertVerifier; |
| 41 class ChannelIDService; |
| 41 class CTVerifier; | 42 class CTVerifier; |
| 42 class ClientSocketHandle; | 43 class ClientSocketHandle; |
| 43 class ServerBoundCertService; | |
| 44 class SingleRequestCertVerifier; | 44 class SingleRequestCertVerifier; |
| 45 class TransportSecurityState; | 45 class TransportSecurityState; |
| 46 class X509Certificate; | 46 class X509Certificate; |
| 47 | 47 |
| 48 // An SSL client socket implemented with Mozilla NSS. | 48 // An SSL client socket implemented with Mozilla NSS. |
| 49 class SSLClientSocketNSS : public SSLClientSocket { | 49 class SSLClientSocketNSS : public SSLClientSocket { |
| 50 public: | 50 public: |
| 51 // Takes ownership of the |transport_socket|, which must already be connected. | 51 // Takes ownership of the |transport_socket|, which must already be connected. |
| 52 // The hostname specified in |host_and_port| will be compared with the name(s) | 52 // The hostname specified in |host_and_port| will be compared with the name(s) |
| 53 // in the server's certificate during the SSL handshake. If SSL client | 53 // in the server's certificate during the SSL handshake. If SSL client |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 // Socket implementation. | 98 // Socket implementation. |
| 99 virtual int Read(IOBuffer* buf, | 99 virtual int Read(IOBuffer* buf, |
| 100 int buf_len, | 100 int buf_len, |
| 101 const CompletionCallback& callback) OVERRIDE; | 101 const CompletionCallback& callback) OVERRIDE; |
| 102 virtual int Write(IOBuffer* buf, | 102 virtual int Write(IOBuffer* buf, |
| 103 int buf_len, | 103 int buf_len, |
| 104 const CompletionCallback& callback) OVERRIDE; | 104 const CompletionCallback& callback) OVERRIDE; |
| 105 virtual int SetReceiveBufferSize(int32 size) OVERRIDE; | 105 virtual int SetReceiveBufferSize(int32 size) OVERRIDE; |
| 106 virtual int SetSendBufferSize(int32 size) OVERRIDE; | 106 virtual int SetSendBufferSize(int32 size) OVERRIDE; |
| 107 virtual ServerBoundCertService* GetServerBoundCertService() const OVERRIDE; | 107 virtual ChannelIDService* GetChannelIDService() const OVERRIDE; |
| 108 | 108 |
| 109 protected: | 109 protected: |
| 110 // SSLClientSocket implementation. | 110 // SSLClientSocket implementation. |
| 111 virtual scoped_refptr<X509Certificate> GetUnverifiedServerCertificateChain() | 111 virtual scoped_refptr<X509Certificate> GetUnverifiedServerCertificateChain() |
| 112 const OVERRIDE; | 112 const OVERRIDE; |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 // Helper class to handle marshalling any NSS interaction to and from the | 115 // Helper class to handle marshalling any NSS interaction to and from the |
| 116 // NSS and network task runners. Not every call needs to happen on the Core | 116 // NSS and network task runners. Not every call needs to happen on the Core |
| 117 class Core; | 117 class Core; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 CertVerifyResult server_cert_verify_result_; | 171 CertVerifyResult server_cert_verify_result_; |
| 172 | 172 |
| 173 CertVerifier* const cert_verifier_; | 173 CertVerifier* const cert_verifier_; |
| 174 scoped_ptr<SingleRequestCertVerifier> verifier_; | 174 scoped_ptr<SingleRequestCertVerifier> verifier_; |
| 175 | 175 |
| 176 // Certificate Transparency: Verifier and result holder. | 176 // Certificate Transparency: Verifier and result holder. |
| 177 ct::CTVerifyResult ct_verify_result_; | 177 ct::CTVerifyResult ct_verify_result_; |
| 178 CTVerifier* cert_transparency_verifier_; | 178 CTVerifier* cert_transparency_verifier_; |
| 179 | 179 |
| 180 // The service for retrieving Channel ID keys. May be NULL. | 180 // The service for retrieving Channel ID keys. May be NULL. |
| 181 ServerBoundCertService* server_bound_cert_service_; | 181 ChannelIDService* channel_id_service_; |
| 182 | 182 |
| 183 // ssl_session_cache_shard_ is an opaque string that partitions the SSL | 183 // ssl_session_cache_shard_ is an opaque string that partitions the SSL |
| 184 // session cache. i.e. sessions created with one value will not attempt to | 184 // session cache. i.e. sessions created with one value will not attempt to |
| 185 // resume on the socket with a different value. | 185 // resume on the socket with a different value. |
| 186 const std::string ssl_session_cache_shard_; | 186 const std::string ssl_session_cache_shard_; |
| 187 | 187 |
| 188 // True if the SSL handshake has been completed. | 188 // True if the SSL handshake has been completed. |
| 189 bool completed_handshake_; | 189 bool completed_handshake_; |
| 190 | 190 |
| 191 State next_handshake_state_; | 191 State next_handshake_state_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 211 // Added the following code Debugging in release mode. | 211 // Added the following code Debugging in release mode. |
| 212 mutable base::Lock lock_; | 212 mutable base::Lock lock_; |
| 213 // This is mutable so that CalledOnValidThread can set it. | 213 // This is mutable so that CalledOnValidThread can set it. |
| 214 // It's guarded by |lock_|. | 214 // It's guarded by |lock_|. |
| 215 mutable base::PlatformThreadId valid_thread_id_; | 215 mutable base::PlatformThreadId valid_thread_id_; |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 } // namespace net | 218 } // namespace net |
| 219 | 219 |
| 220 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ | 220 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ |
| OLD | NEW |