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

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

Issue 416683002: This CL corrects a bug in which the OnHandshakeComplete callback for an ssl session was never called (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@r2
Patch Set: Created 6 years, 5 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
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 <openssl/err.h> 10 #include <openssl/err.h>
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 } 660 }
661 661
662 int SSLClientSocketOpenSSL::SetReceiveBufferSize(int32 size) { 662 int SSLClientSocketOpenSSL::SetReceiveBufferSize(int32 size) {
663 return transport_->socket()->SetReceiveBufferSize(size); 663 return transport_->socket()->SetReceiveBufferSize(size);
664 } 664 }
665 665
666 int SSLClientSocketOpenSSL::SetSendBufferSize(int32 size) { 666 int SSLClientSocketOpenSSL::SetSendBufferSize(int32 size) {
667 return transport_->socket()->SetSendBufferSize(size); 667 return transport_->socket()->SetSendBufferSize(size);
668 } 668 }
669 669
670 // static
671 void SSLClientSocketOpenSSL::OnSessionFinishedCallback(const SSL* ssl,
672 int result,
673 int unused) {
674 if (result == SSL_CB_HANDSHAKE_DONE)
675 SSLContext::GetInstance()->session_cache()->CheckIfSessionFinished(ssl);
676 }
677
670 int SSLClientSocketOpenSSL::Init() { 678 int SSLClientSocketOpenSSL::Init() {
671 DCHECK(!ssl_); 679 DCHECK(!ssl_);
672 DCHECK(!transport_bio_); 680 DCHECK(!transport_bio_);
673 681
674 SSLContext* context = SSLContext::GetInstance(); 682 SSLContext* context = SSLContext::GetInstance();
675 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); 683 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE);
676 684
677 ssl_ = SSL_new(context->ssl_ctx()); 685 ssl_ = SSL_new(context->ssl_ctx());
678 if (!ssl_ || !context->SetClientSocketForSSL(ssl_, this)) 686 if (!ssl_ || !context->SetClientSocketForSSL(ssl_, this))
679 return ERR_UNEXPECTED; 687 return ERR_UNEXPECTED;
680 688
681 if (!SSL_set_tlsext_host_name(ssl_, host_and_port_.host().c_str())) 689 if (!SSL_set_tlsext_host_name(ssl_, host_and_port_.host().c_str()))
682 return ERR_UNEXPECTED; 690 return ERR_UNEXPECTED;
683 691
692 // Set an OpenSSL callback to monitor this SSL*'s connection.
693 SSL_set_info_callback(ssl_, &OnSessionFinishedCallback);
694
684 trying_cached_session_ = context->session_cache()->SetSSLSessionWithKey( 695 trying_cached_session_ = context->session_cache()->SetSSLSessionWithKey(
685 ssl_, GetSessionCacheKey()); 696 ssl_, GetSessionCacheKey());
686 697
687 BIO* ssl_bio = NULL; 698 BIO* ssl_bio = NULL;
688 // 0 => use default buffer sizes. 699 // 0 => use default buffer sizes.
689 if (!BIO_new_bio_pair(&ssl_bio, 0, &transport_bio_, 0)) 700 if (!BIO_new_bio_pair(&ssl_bio, 0, &transport_bio_, 0))
690 return ERR_UNEXPECTED; 701 return ERR_UNEXPECTED;
691 DCHECK(ssl_bio); 702 DCHECK(ssl_bio);
692 DCHECK(transport_bio_); 703 DCHECK(transport_bio_);
693 704
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_; 1480 DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_;
1470 return SSL_TLSEXT_ERR_OK; 1481 return SSL_TLSEXT_ERR_OK;
1471 } 1482 }
1472 1483
1473 scoped_refptr<X509Certificate> 1484 scoped_refptr<X509Certificate>
1474 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { 1485 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const {
1475 return server_cert_; 1486 return server_cert_;
1476 } 1487 }
1477 1488
1478 } // namespace net 1489 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698