| 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 #include <stdint.h> | 12 #include <stdint.h> |
| 13 | 13 |
| 14 #include <memory> |
| 14 #include <string> | 15 #include <string> |
| 15 #include <vector> | 16 #include <vector> |
| 16 | 17 |
| 17 #include "base/memory/scoped_ptr.h" | |
| 18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
| 19 #include "base/threading/platform_thread.h" | 19 #include "base/threading/platform_thread.h" |
| 20 #include "base/time/time.h" | 20 #include "base/time/time.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/nss_memio.h" | 24 #include "net/base/nss_memio.h" |
| 25 #include "net/cert/cert_verifier.h" | 25 #include "net/cert/cert_verifier.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" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 44 | 44 |
| 45 // An SSL client socket implemented with Mozilla NSS. | 45 // An SSL client socket implemented with Mozilla NSS. |
| 46 class SSLClientSocketNSS : public SSLClientSocket { | 46 class SSLClientSocketNSS : public SSLClientSocket { |
| 47 public: | 47 public: |
| 48 // Takes ownership of the |transport_socket|, which must already be connected. | 48 // Takes ownership of the |transport_socket|, which must already be connected. |
| 49 // The hostname specified in |host_and_port| will be compared with the name(s) | 49 // The hostname specified in |host_and_port| will be compared with the name(s) |
| 50 // in the server's certificate during the SSL handshake. If SSL client | 50 // in the server's certificate during the SSL handshake. If SSL client |
| 51 // authentication is requested, the host_and_port field of SSLCertRequestInfo | 51 // authentication is requested, the host_and_port field of SSLCertRequestInfo |
| 52 // will be populated with |host_and_port|. |ssl_config| specifies | 52 // will be populated with |host_and_port|. |ssl_config| specifies |
| 53 // the SSL settings. | 53 // the SSL settings. |
| 54 SSLClientSocketNSS(scoped_ptr<ClientSocketHandle> transport_socket, | 54 SSLClientSocketNSS(std::unique_ptr<ClientSocketHandle> transport_socket, |
| 55 const HostPortPair& host_and_port, | 55 const HostPortPair& host_and_port, |
| 56 const SSLConfig& ssl_config, | 56 const SSLConfig& ssl_config, |
| 57 const SSLClientSocketContext& context); | 57 const SSLClientSocketContext& context); |
| 58 ~SSLClientSocketNSS() override; | 58 ~SSLClientSocketNSS() override; |
| 59 | 59 |
| 60 // SSLClientSocket implementation. | 60 // SSLClientSocket implementation. |
| 61 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override; | 61 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override; |
| 62 NextProtoStatus GetNextProto(std::string* proto) const override; | 62 NextProtoStatus GetNextProto(std::string* proto) const override; |
| 63 | 63 |
| 64 // SSLSocket implementation. | 64 // SSLSocket implementation. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 // each of the SCTs with the corresponding SCTVerifyStatus as it adds it to | 146 // each of the SCTs with the corresponding SCTVerifyStatus as it adds it to |
| 147 // the |ssl_info|.signed_certificate_timestamps list. | 147 // the |ssl_info|.signed_certificate_timestamps list. |
| 148 void AddCTInfoToSSLInfo(SSLInfo* ssl_info) const; | 148 void AddCTInfoToSSLInfo(SSLInfo* ssl_info) const; |
| 149 | 149 |
| 150 // Move last protocol to first place: SSLConfig::next_protos has protocols in | 150 // Move last protocol to first place: SSLConfig::next_protos has protocols in |
| 151 // decreasing order of preference with NPN fallback protocol at the end, but | 151 // decreasing order of preference with NPN fallback protocol at the end, but |
| 152 // NSS moves the first one to the last place before sending them in ALPN, and | 152 // NSS moves the first one to the last place before sending them in ALPN, and |
| 153 // uses the first one as a fallback for NPN. | 153 // uses the first one as a fallback for NPN. |
| 154 static void ReorderNextProtos(NextProtoVector* next_protos); | 154 static void ReorderNextProtos(NextProtoVector* next_protos); |
| 155 | 155 |
| 156 scoped_ptr<ClientSocketHandle> transport_; | 156 std::unique_ptr<ClientSocketHandle> transport_; |
| 157 HostPortPair host_and_port_; | 157 HostPortPair host_and_port_; |
| 158 SSLConfig ssl_config_; | 158 SSLConfig ssl_config_; |
| 159 | 159 |
| 160 scoped_refptr<Core> core_; | 160 scoped_refptr<Core> core_; |
| 161 | 161 |
| 162 CompletionCallback user_connect_callback_; | 162 CompletionCallback user_connect_callback_; |
| 163 | 163 |
| 164 CertVerifyResult server_cert_verify_result_; | 164 CertVerifyResult server_cert_verify_result_; |
| 165 | 165 |
| 166 CertVerifier* const cert_verifier_; | 166 CertVerifier* const cert_verifier_; |
| 167 scoped_ptr<CertVerifier::Request> cert_verifier_request_; | 167 std::unique_ptr<CertVerifier::Request> cert_verifier_request_; |
| 168 | 168 |
| 169 // Certificate Transparency: Verifier and result holder. | 169 // Certificate Transparency: Verifier and result holder. |
| 170 ct::CTVerifyResult ct_verify_result_; | 170 ct::CTVerifyResult ct_verify_result_; |
| 171 CTVerifier* cert_transparency_verifier_; | 171 CTVerifier* cert_transparency_verifier_; |
| 172 | 172 |
| 173 // The service for retrieving Channel ID keys. May be NULL. | 173 // The service for retrieving Channel ID keys. May be NULL. |
| 174 ChannelIDService* channel_id_service_; | 174 ChannelIDService* channel_id_service_; |
| 175 | 175 |
| 176 // ssl_session_cache_shard_ is an opaque string that partitions the SSL | 176 // ssl_session_cache_shard_ is an opaque string that partitions the SSL |
| 177 // session cache. i.e. sessions created with one value will not attempt to | 177 // session cache. i.e. sessions created with one value will not attempt to |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 // Added the following code Debugging in release mode. | 209 // Added the following code Debugging in release mode. |
| 210 mutable base::Lock lock_; | 210 mutable base::Lock lock_; |
| 211 // This is mutable so that CalledOnValidThread can set it. | 211 // This is mutable so that CalledOnValidThread can set it. |
| 212 // It's guarded by |lock_|. | 212 // It's guarded by |lock_|. |
| 213 mutable base::PlatformThreadId valid_thread_id_; | 213 mutable base::PlatformThreadId valid_thread_id_; |
| 214 }; | 214 }; |
| 215 | 215 |
| 216 } // namespace net | 216 } // namespace net |
| 217 | 217 |
| 218 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ | 218 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ |
| OLD | NEW |