| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=455424 | 8 // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=455424 |
| 9 // until NSS 3.12.2 comes out and we update to it. | 9 // until NSS 3.12.2 comes out and we update to it. |
| 10 #define Lock FOO_NSS_Lock | 10 #define Lock FOO_NSS_Lock |
| 11 #include <certt.h> | 11 #include <certt.h> |
| 12 #undef Lock | 12 #undef Lock |
| 13 #include <nspr.h> | 13 #include <nspr.h> |
| 14 #include <nss.h> | 14 #include <nss.h> |
| 15 #include <string> | 15 #include <string> |
| 16 | 16 |
| 17 #include "base/scoped_ptr.h" | 17 #include "base/scoped_ptr.h" |
| 18 #include "net/base/cert_verifier.h" | |
| 19 #include "net/base/cert_verify_result.h" | 18 #include "net/base/cert_verify_result.h" |
| 20 #include "net/base/completion_callback.h" | 19 #include "net/base/completion_callback.h" |
| 21 #include "net/base/nss_memio.h" | 20 #include "net/base/nss_memio.h" |
| 22 #include "net/base/ssl_config_service.h" | 21 #include "net/base/ssl_config_service.h" |
| 23 #include "net/socket/ssl_client_socket.h" | 22 #include "net/socket/ssl_client_socket.h" |
| 24 | 23 |
| 25 namespace net { | 24 namespace net { |
| 26 | 25 |
| 26 class CertVerifier; |
| 27 class X509Certificate; | 27 class X509Certificate; |
| 28 | 28 |
| 29 // An SSL client socket implemented with Mozilla NSS. | 29 // An SSL client socket implemented with Mozilla NSS. |
| 30 class SSLClientSocketNSS : public SSLClientSocket { | 30 class SSLClientSocketNSS : public SSLClientSocket { |
| 31 public: | 31 public: |
| 32 // Takes ownership of the transport_socket, which may already be connected. | 32 // Takes ownership of the transport_socket, which may already be connected. |
| 33 // The given hostname will be compared with the name(s) in the server's | 33 // The given hostname will be compared with the name(s) in the server's |
| 34 // certificate during the SSL handshake. ssl_config specifies the SSL | 34 // certificate during the SSL handshake. ssl_config specifies the SSL |
| 35 // settings. | 35 // settings. |
| 36 SSLClientSocketNSS(ClientSocket* transport_socket, | 36 SSLClientSocketNSS(ClientSocket* transport_socket, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 CompletionCallback* user_callback_; | 92 CompletionCallback* user_callback_; |
| 93 | 93 |
| 94 // Used by both Read and Write functions. | 94 // Used by both Read and Write functions. |
| 95 scoped_refptr<IOBuffer> user_buf_; | 95 scoped_refptr<IOBuffer> user_buf_; |
| 96 int user_buf_len_; | 96 int user_buf_len_; |
| 97 | 97 |
| 98 // Set when handshake finishes. | 98 // Set when handshake finishes. |
| 99 scoped_refptr<X509Certificate> server_cert_; | 99 scoped_refptr<X509Certificate> server_cert_; |
| 100 CertVerifyResult server_cert_verify_result_; | 100 CertVerifyResult server_cert_verify_result_; |
| 101 | 101 |
| 102 CertVerifier verifier_; | 102 scoped_ptr<CertVerifier> verifier_; |
| 103 | 103 |
| 104 bool completed_handshake_; | 104 bool completed_handshake_; |
| 105 | 105 |
| 106 enum State { | 106 enum State { |
| 107 STATE_NONE, | 107 STATE_NONE, |
| 108 STATE_HANDSHAKE_READ, | 108 STATE_HANDSHAKE_READ, |
| 109 STATE_VERIFY_CERT, | 109 STATE_VERIFY_CERT, |
| 110 STATE_VERIFY_CERT_COMPLETE, | 110 STATE_VERIFY_CERT_COMPLETE, |
| 111 STATE_PAYLOAD_WRITE, | 111 STATE_PAYLOAD_WRITE, |
| 112 STATE_PAYLOAD_READ, | 112 STATE_PAYLOAD_READ, |
| 113 }; | 113 }; |
| 114 State next_state_; | 114 State next_state_; |
| 115 | 115 |
| 116 // The NSS SSL state machine | 116 // The NSS SSL state machine |
| 117 PRFileDesc* nss_fd_; | 117 PRFileDesc* nss_fd_; |
| 118 | 118 |
| 119 // Buffers for the network end of the SSL state machine | 119 // Buffers for the network end of the SSL state machine |
| 120 memio_Private* nss_bufs_; | 120 memio_Private* nss_bufs_; |
| 121 | 121 |
| 122 static bool nss_options_initialized_; | 122 static bool nss_options_initialized_; |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 } // namespace net | 125 } // namespace net |
| 126 | 126 |
| 127 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ | 127 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ |
| OLD | NEW |