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

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

Issue 2061433002: Roll base to 9e74307b276b2f9988005c0e97e85ee222586f79. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « net/quic/crypto/quic_random.cc ('k') | net/socket/websocket_endpoint_lock_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // OpenSSL binding for SSLClientSocket. The class layout and general principle 5 // OpenSSL binding for SSLClientSocket. The class layout and general principle
6 // of operation is derived from SSLClientSocketNSS. 6 // of operation is derived from SSLClientSocketNSS.
7 7
8 #include "net/socket/ssl_client_socket_openssl.h" 8 #include "net/socket/ssl_client_socket_openssl.h"
9 9
10 #include <errno.h> 10 #include <errno.h>
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 }; 195 };
196 196
197 base::LazyInstance<PlatformKeyTaskRunner>::Leaky g_platform_key_task_runner = 197 base::LazyInstance<PlatformKeyTaskRunner>::Leaky g_platform_key_task_runner =
198 LAZY_INSTANCE_INITIALIZER; 198 LAZY_INSTANCE_INITIALIZER;
199 #endif // !USE_OPENSSL_CERTS 199 #endif // !USE_OPENSSL_CERTS
200 200
201 } // namespace 201 } // namespace
202 202
203 class SSLClientSocketOpenSSL::SSLContext { 203 class SSLClientSocketOpenSSL::SSLContext {
204 public: 204 public:
205 static SSLContext* GetInstance() { return Singleton<SSLContext>::get(); } 205 static SSLContext* GetInstance() {
206 return base::Singleton<SSLContext>::get();
207 }
206 SSL_CTX* ssl_ctx() { return ssl_ctx_.get(); } 208 SSL_CTX* ssl_ctx() { return ssl_ctx_.get(); }
207 SSLClientSessionCacheOpenSSL* session_cache() { return &session_cache_; } 209 SSLClientSessionCacheOpenSSL* session_cache() { return &session_cache_; }
208 210
209 SSLClientSocketOpenSSL* GetClientSocketFromSSL(const SSL* ssl) { 211 SSLClientSocketOpenSSL* GetClientSocketFromSSL(const SSL* ssl) {
210 DCHECK(ssl); 212 DCHECK(ssl);
211 SSLClientSocketOpenSSL* socket = static_cast<SSLClientSocketOpenSSL*>( 213 SSLClientSocketOpenSSL* socket = static_cast<SSLClientSocketOpenSSL*>(
212 SSL_get_ex_data(ssl, ssl_socket_data_index_)); 214 SSL_get_ex_data(ssl, ssl_socket_data_index_));
213 DCHECK(socket); 215 DCHECK(socket);
214 return socket; 216 return socket;
215 } 217 }
216 218
217 bool SetClientSocketForSSL(SSL* ssl, SSLClientSocketOpenSSL* socket) { 219 bool SetClientSocketForSSL(SSL* ssl, SSLClientSocketOpenSSL* socket) {
218 return SSL_set_ex_data(ssl, ssl_socket_data_index_, socket) != 0; 220 return SSL_set_ex_data(ssl, ssl_socket_data_index_, socket) != 0;
219 } 221 }
220 222
221 static const SSL_PRIVATE_KEY_METHOD kPrivateKeyMethod; 223 static const SSL_PRIVATE_KEY_METHOD kPrivateKeyMethod;
222 224
223 private: 225 private:
224 friend struct DefaultSingletonTraits<SSLContext>; 226 friend struct base::DefaultSingletonTraits<SSLContext>;
225 227
226 SSLContext() : session_cache_(SSLClientSessionCacheOpenSSL::Config()) { 228 SSLContext() : session_cache_(SSLClientSessionCacheOpenSSL::Config()) {
227 crypto::EnsureOpenSSLInit(); 229 crypto::EnsureOpenSSLInit();
228 ssl_socket_data_index_ = SSL_get_ex_new_index(0, 0, 0, 0, 0); 230 ssl_socket_data_index_ = SSL_get_ex_new_index(0, 0, 0, 0, 0);
229 DCHECK_NE(ssl_socket_data_index_, -1); 231 DCHECK_NE(ssl_socket_data_index_, -1);
230 ssl_ctx_.reset(SSL_CTX_new(SSLv23_client_method())); 232 ssl_ctx_.reset(SSL_CTX_new(SSLv23_client_method()));
231 SSL_CTX_set_cert_verify_callback(ssl_ctx_.get(), CertVerifyCallback, NULL); 233 SSL_CTX_set_cert_verify_callback(ssl_ctx_.get(), CertVerifyCallback, NULL);
232 SSL_CTX_set_cert_cb(ssl_ctx_.get(), ClientCertRequestCallback, NULL); 234 SSL_CTX_set_cert_cb(ssl_ctx_.get(), ClientCertRequestCallback, NULL);
233 SSL_CTX_set_verify(ssl_ctx_.get(), SSL_VERIFY_PEER, NULL); 235 SSL_CTX_set_verify(ssl_ctx_.get(), SSL_VERIFY_PEER, NULL);
234 // This stops |SSL_shutdown| from generating the close_notify message, which 236 // This stops |SSL_shutdown| from generating the close_notify message, which
(...skipping 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 OnHandshakeIOComplete(signature_result_); 2145 OnHandshakeIOComplete(signature_result_);
2144 return; 2146 return;
2145 } 2147 }
2146 2148
2147 // During a renegotiation, either Read or Write calls may be blocked on an 2149 // During a renegotiation, either Read or Write calls may be blocked on an
2148 // asynchronous private key operation. 2150 // asynchronous private key operation.
2149 PumpReadWriteEvents(); 2151 PumpReadWriteEvents();
2150 } 2152 }
2151 2153
2152 } // namespace net 2154 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/quic_random.cc ('k') | net/socket/websocket_endpoint_lock_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698