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

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

Issue 3846005: Revert 62918 - net: clean up SSLHostInfo construction.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « net/socket/ssl_client_socket_nss.h ('k') | net/socket/ssl_client_socket_nss_factory.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) 2010 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 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived 5 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived
6 // from AuthCertificateCallback() in 6 // from AuthCertificateCallback() in
7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. 7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp.
8 8
9 /* ***** BEGIN LICENSE BLOCK ***** 9 /* ***** BEGIN LICENSE BLOCK *****
10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 393
394 } // namespace 394 } // namespace
395 395
396 #if defined(OS_WIN) 396 #if defined(OS_WIN)
397 // static 397 // static
398 HCERTSTORE SSLClientSocketNSS::cert_store_ = NULL; 398 HCERTSTORE SSLClientSocketNSS::cert_store_ = NULL;
399 #endif 399 #endif
400 400
401 SSLClientSocketNSS::SSLClientSocketNSS(ClientSocketHandle* transport_socket, 401 SSLClientSocketNSS::SSLClientSocketNSS(ClientSocketHandle* transport_socket,
402 const std::string& hostname, 402 const std::string& hostname,
403 const SSLConfig& ssl_config, 403 const SSLConfig& ssl_config)
404 SSLHostInfo* ssl_host_info)
405 : ALLOW_THIS_IN_INITIALIZER_LIST(buffer_send_callback_( 404 : ALLOW_THIS_IN_INITIALIZER_LIST(buffer_send_callback_(
406 this, &SSLClientSocketNSS::BufferSendComplete)), 405 this, &SSLClientSocketNSS::BufferSendComplete)),
407 ALLOW_THIS_IN_INITIALIZER_LIST(buffer_recv_callback_( 406 ALLOW_THIS_IN_INITIALIZER_LIST(buffer_recv_callback_(
408 this, &SSLClientSocketNSS::BufferRecvComplete)), 407 this, &SSLClientSocketNSS::BufferRecvComplete)),
409 transport_send_busy_(false), 408 transport_send_busy_(false),
410 transport_recv_busy_(false), 409 transport_recv_busy_(false),
411 corked_(false), 410 corked_(false),
412 ALLOW_THIS_IN_INITIALIZER_LIST(handshake_io_callback_( 411 ALLOW_THIS_IN_INITIALIZER_LIST(handshake_io_callback_(
413 this, &SSLClientSocketNSS::OnHandshakeIOComplete)), 412 this, &SSLClientSocketNSS::OnHandshakeIOComplete)),
414 transport_(transport_socket), 413 transport_(transport_socket),
(...skipping 10 matching lines...) Expand all
425 completed_handshake_(false), 424 completed_handshake_(false),
426 pseudo_connected_(false), 425 pseudo_connected_(false),
427 eset_mitm_detected_(false), 426 eset_mitm_detected_(false),
428 netnanny_mitm_detected_(false), 427 netnanny_mitm_detected_(false),
429 dnssec_provider_(NULL), 428 dnssec_provider_(NULL),
430 next_handshake_state_(STATE_NONE), 429 next_handshake_state_(STATE_NONE),
431 nss_fd_(NULL), 430 nss_fd_(NULL),
432 nss_bufs_(NULL), 431 nss_bufs_(NULL),
433 net_log_(transport_socket->socket()->NetLog()), 432 net_log_(transport_socket->socket()->NetLog()),
434 predicted_npn_status_(kNextProtoUnsupported), 433 predicted_npn_status_(kNextProtoUnsupported),
435 predicted_npn_proto_used_(false), 434 predicted_npn_proto_used_(false) {
436 ssl_host_info_(ssl_host_info) {
437 EnterFunction(""); 435 EnterFunction("");
438 } 436 }
439 437
440 SSLClientSocketNSS::~SSLClientSocketNSS() { 438 SSLClientSocketNSS::~SSLClientSocketNSS() {
441 EnterFunction(""); 439 EnterFunction("");
442 Disconnect(); 440 Disconnect();
443 LeaveFunction(""); 441 LeaveFunction("");
444 } 442 }
445 443
446 int SSLClientSocketNSS::Init() { 444 int SSLClientSocketNSS::Init() {
(...skipping 15 matching lines...) Expand all
462 } 460 }
463 461
464 // This is a version number of the Snap Start information saved by 462 // This is a version number of the Snap Start information saved by
465 // |SaveSnapStartInfo| and loaded by |LoadSnapStartInfo|. Since the information 463 // |SaveSnapStartInfo| and loaded by |LoadSnapStartInfo|. Since the information
466 // can be saved on disk we might have version skew in the future. Any data with 464 // can be saved on disk we might have version skew in the future. Any data with
467 // a different version is ignored by |LoadSnapStartInfo|. 465 // a different version is ignored by |LoadSnapStartInfo|.
468 static const uint8 kSnapStartInfoVersion = 0; 466 static const uint8 kSnapStartInfoVersion = 0;
469 467
470 // SaveSnapStartInfo serialises the information needed to perform a Snap Start 468 // SaveSnapStartInfo serialises the information needed to perform a Snap Start
471 // with this server in the future (if any) and tells 469 // with this server in the future (if any) and tells
472 // |ssl_host_info_| to preserve it. 470 // |ssl_config_.ssl_host_info| to preserve it.
473 void SSLClientSocketNSS::SaveSnapStartInfo() { 471 void SSLClientSocketNSS::SaveSnapStartInfo() {
474 if (!ssl_host_info_.get()) 472 if (!ssl_config_.ssl_host_info.get())
475 return; 473 return;
476 474
477 SECStatus rv; 475 SECStatus rv;
478 SSLSnapStartResult snap_start_type; 476 SSLSnapStartResult snap_start_type;
479 rv = SSL_GetSnapStartResult(nss_fd_, &snap_start_type); 477 rv = SSL_GetSnapStartResult(nss_fd_, &snap_start_type);
480 if (rv != SECSuccess) { 478 if (rv != SECSuccess) {
481 NOTREACHED(); 479 NOTREACHED();
482 return; 480 return;
483 } 481 }
484 LOG(ERROR) << "Snap Start: " << snap_start_type << " " << hostname_; 482 LOG(ERROR) << "Snap Start: " << snap_start_type << " " << hostname_;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 node = CERT_LIST_NEXT(node), i++) { 585 node = CERT_LIST_NEXT(node), i++) {
588 data[j++] = node->cert->derCert.len >> 8; 586 data[j++] = node->cert->derCert.len >> 8;
589 data[j++] = node->cert->derCert.len; 587 data[j++] = node->cert->derCert.len;
590 memcpy(&data[j], node->cert->derCert.data, node->cert->derCert.len); 588 memcpy(&data[j], node->cert->derCert.data, node->cert->derCert.len);
591 j += node->cert->derCert.len; 589 j += node->cert->derCert.len;
592 } 590 }
593 591
594 DCHECK_EQ(j, len); 592 DCHECK_EQ(j, len);
595 593
596 LOG(ERROR) << "Setting Snap Start info " << hostname_ << " " << len; 594 LOG(ERROR) << "Setting Snap Start info " << hostname_ << " " << len;
597 ssl_host_info_->Set(std::string( 595 ssl_config_.ssl_host_info->Set(std::string(
598 reinterpret_cast<const char *>(&data[0]), len)); 596 reinterpret_cast<const char *>(&data[0]), len));
599 597
600 CERT_DestroyCertList(cert_list); 598 CERT_DestroyCertList(cert_list);
601 } 599 }
602 600
603 static void DestroyCertificates(CERTCertificate** certs, unsigned len) { 601 static void DestroyCertificates(CERTCertificate** certs, unsigned len) {
604 for (unsigned i = 0; i < len; i++) 602 for (unsigned i = 0; i < len; i++)
605 CERT_DestroyCertificate(certs[i]); 603 CERT_DestroyCertificate(certs[i]);
606 } 604 }
607 605
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT, NULL); 729 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT, NULL);
732 return rv; 730 return rv;
733 } 731 }
734 732
735 rv = InitializeSSLOptions(); 733 rv = InitializeSSLOptions();
736 if (rv != OK) { 734 if (rv != OK) {
737 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT, NULL); 735 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT, NULL);
738 return rv; 736 return rv;
739 } 737 }
740 738
741 if (ssl_config_.snap_start_enabled && ssl_host_info_.get()) { 739 if (ssl_config_.snap_start_enabled && ssl_config_.ssl_host_info.get()) {
742 GotoState(STATE_SNAP_START_LOAD_INFO); 740 GotoState(STATE_SNAP_START_LOAD_INFO);
743 } else { 741 } else {
744 GotoState(STATE_HANDSHAKE); 742 GotoState(STATE_HANDSHAKE);
745 } 743 }
746 744
747 rv = DoHandshakeLoop(OK); 745 rv = DoHandshakeLoop(OK);
748 if (rv == ERR_IO_PENDING) { 746 if (rv == ERR_IO_PENDING) {
749 if (pseudo_connected_) { 747 if (pseudo_connected_) {
750 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT, NULL); 748 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT, NULL);
751 rv = OK; 749 rv = OK;
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1964 1962
1965 that->handshake_callback_called_ = true; 1963 that->handshake_callback_called_ = true;
1966 1964
1967 that->UpdateServerCert(); 1965 that->UpdateServerCert();
1968 1966
1969 that->CheckSecureRenegotiation(); 1967 that->CheckSecureRenegotiation();
1970 } 1968 }
1971 1969
1972 int SSLClientSocketNSS::DoSnapStartLoadInfo() { 1970 int SSLClientSocketNSS::DoSnapStartLoadInfo() {
1973 EnterFunction(""); 1971 EnterFunction("");
1974 int rv = ssl_host_info_->WaitForDataReady(&handshake_io_callback_); 1972 int rv = ssl_config_.ssl_host_info->WaitForDataReady(&handshake_io_callback_);
1975 1973
1976 if (rv == OK) { 1974 if (rv == OK) {
1977 LOG(ERROR) << "SSL host info size " << hostname_ << " " 1975 LOG(ERROR) << "SSL host info size " << hostname_ << " "
1978 << ssl_host_info_->data().size(); 1976 << ssl_config_.ssl_host_info->data().size();
1979 if (LoadSnapStartInfo(ssl_host_info_->data())) { 1977 if (LoadSnapStartInfo(ssl_config_.ssl_host_info->data())) {
1980 pseudo_connected_ = true; 1978 pseudo_connected_ = true;
1981 GotoState(STATE_SNAP_START_WAIT_FOR_WRITE); 1979 GotoState(STATE_SNAP_START_WAIT_FOR_WRITE);
1982 if (user_connect_callback_) 1980 if (user_connect_callback_)
1983 DoConnectCallback(OK); 1981 DoConnectCallback(OK);
1984 } else { 1982 } else {
1985 GotoState(STATE_HANDSHAKE); 1983 GotoState(STATE_HANDSHAKE);
1986 } 1984 }
1987 } else { 1985 } else {
1988 DCHECK_EQ(ERR_IO_PENDING, rv); 1986 DCHECK_EQ(ERR_IO_PENDING, rv);
1989 GotoState(STATE_SNAP_START_LOAD_INFO); 1987 GotoState(STATE_SNAP_START_LOAD_INFO);
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
2449 return ERR_IO_PENDING; 2447 return ERR_IO_PENDING;
2450 } 2448 }
2451 LeaveFunction(""); 2449 LeaveFunction("");
2452 rv = MapNSPRError(prerr); 2450 rv = MapNSPRError(prerr);
2453 net_log_.AddEvent(NetLog::TYPE_SSL_WRITE_ERROR, 2451 net_log_.AddEvent(NetLog::TYPE_SSL_WRITE_ERROR,
2454 new SSLErrorParams(rv, prerr)); 2452 new SSLErrorParams(rv, prerr));
2455 return rv; 2453 return rv;
2456 } 2454 }
2457 2455
2458 } // namespace net 2456 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_nss.h ('k') | net/socket/ssl_client_socket_nss_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698