OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "net/socket/ssl_client_socket_win.h" | 5 #include "net/socket/ssl_client_socket_win.h" |
6 | 6 |
7 #include <schnlsp.h> | 7 #include <schnlsp.h> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/lock.h" | 10 #include "base/lock.h" |
11 #include "base/singleton.h" | 11 #include "base/singleton.h" |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 isc_status_(SEC_E_OK), | 315 isc_status_(SEC_E_OK), |
316 payload_send_buffer_len_(0), | 316 payload_send_buffer_len_(0), |
317 bytes_sent_(0), | 317 bytes_sent_(0), |
318 decrypted_ptr_(NULL), | 318 decrypted_ptr_(NULL), |
319 bytes_decrypted_(0), | 319 bytes_decrypted_(0), |
320 received_ptr_(NULL), | 320 received_ptr_(NULL), |
321 bytes_received_(0), | 321 bytes_received_(0), |
322 writing_first_token_(false), | 322 writing_first_token_(false), |
323 ignore_ok_result_(false), | 323 ignore_ok_result_(false), |
324 renegotiating_(false), | 324 renegotiating_(false), |
325 need_more_data_(false) { | 325 need_more_data_(false), |
| 326 net_log_(transport_socket->NetLog()) { |
326 memset(&stream_sizes_, 0, sizeof(stream_sizes_)); | 327 memset(&stream_sizes_, 0, sizeof(stream_sizes_)); |
327 memset(in_buffers_, 0, sizeof(in_buffers_)); | 328 memset(in_buffers_, 0, sizeof(in_buffers_)); |
328 memset(&send_buffer_, 0, sizeof(send_buffer_)); | 329 memset(&send_buffer_, 0, sizeof(send_buffer_)); |
329 memset(&ctxt_, 0, sizeof(ctxt_)); | 330 memset(&ctxt_, 0, sizeof(ctxt_)); |
330 } | 331 } |
331 | 332 |
332 SSLClientSocketWin::~SSLClientSocketWin() { | 333 SSLClientSocketWin::~SSLClientSocketWin() { |
333 Disconnect(); | 334 Disconnect(); |
334 } | 335 } |
335 | 336 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 BOOL ok = CertCloseStore(my_cert_store, CERT_CLOSE_STORE_CHECK_FLAG); | 424 BOOL ok = CertCloseStore(my_cert_store, CERT_CLOSE_STORE_CHECK_FLAG); |
424 DCHECK(ok); | 425 DCHECK(ok); |
425 } | 426 } |
426 | 427 |
427 SSLClientSocket::NextProtoStatus | 428 SSLClientSocket::NextProtoStatus |
428 SSLClientSocketWin::GetNextProto(std::string* proto) { | 429 SSLClientSocketWin::GetNextProto(std::string* proto) { |
429 proto->clear(); | 430 proto->clear(); |
430 return kNextProtoUnsupported; | 431 return kNextProtoUnsupported; |
431 } | 432 } |
432 | 433 |
433 int SSLClientSocketWin::Connect(CompletionCallback* callback, | 434 int SSLClientSocketWin::Connect(CompletionCallback* callback) { |
434 const BoundNetLog& net_log) { | |
435 DCHECK(transport_.get()); | 435 DCHECK(transport_.get()); |
436 DCHECK(next_state_ == STATE_NONE); | 436 DCHECK(next_state_ == STATE_NONE); |
437 DCHECK(!user_connect_callback_); | 437 DCHECK(!user_connect_callback_); |
438 | 438 |
439 net_log.BeginEvent(NetLog::TYPE_SSL_CONNECT); | 439 net_log_.BeginEvent(NetLog::TYPE_SSL_CONNECT); |
440 | 440 |
441 int rv = InitializeSSLContext(); | 441 int rv = InitializeSSLContext(); |
442 if (rv != OK) { | 442 if (rv != OK) { |
443 net_log.EndEvent(NetLog::TYPE_SSL_CONNECT); | 443 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT); |
444 return rv; | 444 return rv; |
445 } | 445 } |
446 | 446 |
447 writing_first_token_ = true; | 447 writing_first_token_ = true; |
448 next_state_ = STATE_HANDSHAKE_WRITE; | 448 next_state_ = STATE_HANDSHAKE_WRITE; |
449 rv = DoLoop(OK); | 449 rv = DoLoop(OK); |
450 if (rv == ERR_IO_PENDING) { | 450 if (rv == ERR_IO_PENDING) { |
451 user_connect_callback_ = callback; | 451 user_connect_callback_ = callback; |
452 net_log_ = net_log; | |
453 } else { | 452 } else { |
454 net_log.EndEvent(NetLog::TYPE_SSL_CONNECT); | 453 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT); |
455 } | 454 } |
456 return rv; | 455 return rv; |
457 } | 456 } |
458 | 457 |
459 int SSLClientSocketWin::InitializeSSLContext() { | 458 int SSLClientSocketWin::InitializeSSLContext() { |
460 int ssl_version_mask = 0; | 459 int ssl_version_mask = 0; |
461 if (ssl_config_.ssl2_enabled) | 460 if (ssl_config_.ssl2_enabled) |
462 ssl_version_mask |= SSL2; | 461 ssl_version_mask |= SSL2; |
463 if (ssl_config_.ssl3_enabled) | 462 if (ssl_config_.ssl3_enabled) |
464 ssl_version_mask |= SSL3; | 463 ssl_version_mask |= SSL3; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 // renegotiation process starts). So we complete the Read here. | 648 // renegotiation process starts). So we complete the Read here. |
650 if (!user_connect_callback_) { | 649 if (!user_connect_callback_) { |
651 CompletionCallback* c = user_read_callback_; | 650 CompletionCallback* c = user_read_callback_; |
652 user_read_callback_ = NULL; | 651 user_read_callback_ = NULL; |
653 user_read_buf_ = NULL; | 652 user_read_buf_ = NULL; |
654 user_read_buf_len_ = 0; | 653 user_read_buf_len_ = 0; |
655 c->Run(rv); | 654 c->Run(rv); |
656 return; | 655 return; |
657 } | 656 } |
658 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT); | 657 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT); |
659 net_log_ = BoundNetLog(); | |
660 CompletionCallback* c = user_connect_callback_; | 658 CompletionCallback* c = user_connect_callback_; |
661 user_connect_callback_ = NULL; | 659 user_connect_callback_ = NULL; |
662 c->Run(rv); | 660 c->Run(rv); |
663 } | 661 } |
664 } | 662 } |
665 | 663 |
666 void SSLClientSocketWin::OnReadComplete(int result) { | 664 void SSLClientSocketWin::OnReadComplete(int result) { |
667 DCHECK(completed_handshake()); | 665 DCHECK(completed_handshake()); |
668 | 666 |
669 result = DoPayloadReadComplete(result); | 667 result = DoPayloadReadComplete(result); |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1338 UpdateConnectionTypeHistograms(CONNECTION_SSL_MD2_CA); | 1336 UpdateConnectionTypeHistograms(CONNECTION_SSL_MD2_CA); |
1339 } | 1337 } |
1340 | 1338 |
1341 void SSLClientSocketWin::FreeSendBuffer() { | 1339 void SSLClientSocketWin::FreeSendBuffer() { |
1342 SECURITY_STATUS status = FreeContextBuffer(send_buffer_.pvBuffer); | 1340 SECURITY_STATUS status = FreeContextBuffer(send_buffer_.pvBuffer); |
1343 DCHECK(status == SEC_E_OK); | 1341 DCHECK(status == SEC_E_OK); |
1344 memset(&send_buffer_, 0, sizeof(send_buffer_)); | 1342 memset(&send_buffer_, 0, sizeof(send_buffer_)); |
1345 } | 1343 } |
1346 | 1344 |
1347 } // namespace net | 1345 } // namespace net |
OLD | NEW |