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

Issue 416683002: This CL corrects a bug in which the OnHandshakeComplete callback for an ssl session was never called (Closed)

Created:
6 years, 5 months ago by mshelley
Modified:
6 years, 4 months ago
CC:
chromium-reviews, cbentzel+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@r2
Project:
chromium
Visibility:
Public.

Description

This CL corrects a bug in which the OnHandshakeComplete callback for an ssl session was never called if that session had an empty session id (i.e. the session wasn't added to the cache). This CL sets the OpenSSL info_callback such that CheckIfSessionAdded will be run whenever an OpenSSL session has finished its handshake. Previously, CheckIfSessionAdded was called in NewSessionCallbackStatic. NewSessionCallbackStatic is only called when a session is added to the cache. Thus, leading connections with sessions that were not added to the cache would force their pending jobs to wait indefinitely instead of letting the jobs proceed at the completion of the leading job's connection. R=mmenke@chromium.org,rsleevi@chromium.org,wtc@chromium.org, davidben@chromium.org BUG=398967 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=288024

Patch Set 1 : #

Total comments: 4

Patch Set 2 : Removed session to callback map from SSLSessionCallback, added unittest #

Total comments: 6

Patch Set 3 : Added SessionIsGood method to replace completion count when checking if a session is finished. #

Total comments: 10

Patch Set 4 : Renamed server command line flag and fixed other cl comments #

Total comments: 6

Patch Set 5 : Fixed typos & updated flag description #

Total comments: 12

Patch Set 6 : Fixed comment #

Patch Set 7 : Changed the names of several confusingly named methods. #

Total comments: 17
Unified diffs Side-by-side diffs Delta from patch set Stats (+104 lines, -81 lines) Patch
M net/socket/ssl_client_socket_nss.cc View 1 1 chunk +1 line, -0 lines 0 comments Download
M net/socket/ssl_client_socket_openssl.h View 1 2 3 4 5 6 3 chunks +11 lines, -0 lines 6 comments Download
M net/socket/ssl_client_socket_openssl.cc View 1 2 3 4 5 6 7 chunks +32 lines, -10 lines 5 comments Download
M net/socket/ssl_client_socket_unittest.cc View 1 2 3 4 5 6 2 chunks +36 lines, -3 lines 3 comments Download
M net/socket/ssl_session_cache_openssl.h View 1 3 4 5 6 1 chunk +0 lines, -7 lines 1 comment Download
M net/socket/ssl_session_cache_openssl.cc View 1 2 3 4 5 6 6 chunks +0 lines, -56 lines 1 comment Download
M net/test/spawned_test_server/base_test_server.h View 1 2 1 chunk +4 lines, -0 lines 1 comment Download
M net/test/spawned_test_server/base_test_server.cc View 1 2 3 4 3 chunks +8 lines, -2 lines 0 comments Download
M net/tools/testserver/testserver.py View 1 2 3 4 5 4 chunks +12 lines, -3 lines 0 comments Download

Messages

Total messages: 22 (0 generated)
mshelley
6 years, 5 months ago (2014-07-23 21:15:49 UTC) #1
Ryan Sleevi
Adding DavidBen for BoringSSL, although he did steer you this way. This is what I ...
6 years, 5 months ago (2014-07-25 21:42:38 UTC) #2
davidben
Sorry about the delay. This lgtm. A couple of comments: - Is there a bug ...
6 years, 4 months ago (2014-07-29 19:16:02 UTC) #3
Ryan Sleevi
I agree with David on both points, and I think this CL is a good ...
6 years, 4 months ago (2014-07-29 23:21:04 UTC) #4
mshelley
Sorry for the delay -- I wanted to get another CL that this CL is ...
6 years, 4 months ago (2014-08-05 23:17:11 UTC) #5
Ryan Sleevi
https://codereview.chromium.org/416683002/diff/120001/net/socket/ssl_client_socket_openssl.cc File net/socket/ssl_client_socket_openssl.cc (right): https://codereview.chromium.org/416683002/diff/120001/net/socket/ssl_client_socket_openssl.cc#newcode1594 net/socket/ssl_client_socket_openssl.cc:1594: if (++session_completion_count_ == 2) { Is this still necessary ...
6 years, 4 months ago (2014-08-06 01:31:30 UTC) #6
mshelley
https://codereview.chromium.org/416683002/diff/120001/net/socket/ssl_client_socket_openssl.cc File net/socket/ssl_client_socket_openssl.cc (right): https://codereview.chromium.org/416683002/diff/120001/net/socket/ssl_client_socket_openssl.cc#newcode1594 net/socket/ssl_client_socket_openssl.cc:1594: if (++session_completion_count_ == 2) { On 2014/08/06 01:31:30, Ryan ...
6 years, 4 months ago (2014-08-06 03:09:31 UTC) #7
Ryan Sleevi
Mostly LG, but several (hopefully quick/easy) cleanups https://codereview.chromium.org/416683002/diff/180001/net/socket/ssl_client_socket_openssl.h File net/socket/ssl_client_socket_openssl.h (right): https://codereview.chromium.org/416683002/diff/180001/net/socket/ssl_client_socket_openssl.h#newcode99 net/socket/ssl_client_socket_openssl.h:99: void SetSSLHandshakeComplete(); ...
6 years, 4 months ago (2014-08-06 23:42:04 UTC) #8
mshelley
https://codereview.chromium.org/416683002/diff/180001/net/socket/ssl_client_socket_openssl.h File net/socket/ssl_client_socket_openssl.h (right): https://codereview.chromium.org/416683002/diff/180001/net/socket/ssl_client_socket_openssl.h#newcode99 net/socket/ssl_client_socket_openssl.h:99: void SetSSLHandshakeComplete(); On 2014/08/06 23:42:03, Ryan Sleevi wrote: > ...
6 years, 4 months ago (2014-08-07 00:22:00 UTC) #9
Ryan Sleevi
https://codereview.chromium.org/416683002/diff/200001/net/socket/ssl_client_socket_unittest.cc File net/socket/ssl_client_socket_unittest.cc (right): https://codereview.chromium.org/416683002/diff/200001/net/socket/ssl_client_socket_unittest.cc#newcode2725 net/socket/ssl_client_socket_unittest.cc:2725: LOG(ERROR) << "SSL Socket prematurely connected"; Pst: Nuke these ...
6 years, 4 months ago (2014-08-07 00:27:42 UTC) #10
mshelley
https://codereview.chromium.org/416683002/diff/200001/net/socket/ssl_client_socket_unittest.cc File net/socket/ssl_client_socket_unittest.cc (right): https://codereview.chromium.org/416683002/diff/200001/net/socket/ssl_client_socket_unittest.cc#newcode2725 net/socket/ssl_client_socket_unittest.cc:2725: LOG(ERROR) << "SSL Socket prematurely connected"; On 2014/08/07 00:27:41, ...
6 years, 4 months ago (2014-08-07 00:55:05 UTC) #11
Ryan Sleevi
LGTM, mod one last comment nit. https://codereview.chromium.org/416683002/diff/220001/net/tools/testserver/testserver.py File net/tools/testserver/testserver.py (right): https://codereview.chromium.org/416683002/diff/220001/net/tools/testserver/testserver.py#newcode2097 net/tools/testserver/testserver.py:2097: 'session cache.') 'TLS ...
6 years, 4 months ago (2014-08-07 01:08:34 UTC) #12
mshelley
The CQ bit was checked by mshelley@chromium.org
6 years, 4 months ago (2014-08-07 01:59:23 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/mshelley@chromium.org/416683002/240001
6 years, 4 months ago (2014-08-07 02:00:10 UTC) #14
mshelley
The CQ bit was unchecked by mshelley@chromium.org
6 years, 4 months ago (2014-08-07 02:01:11 UTC) #15
Ryan Sleevi
Oh, also, update description/commit note before committing eg: "Ensure OnHandshakeComplete is called if the TLS ...
6 years, 4 months ago (2014-08-07 02:06:53 UTC) #16
Ryan Sleevi
On 2014/08/07 02:06:53, Ryan Sleevi wrote: > Oh, also, update description/commit note before committing > ...
6 years, 4 months ago (2014-08-07 02:08:03 UTC) #17
wtc
Review comments on patch set 5: 1. I believe this CL can be further simplified. ...
6 years, 4 months ago (2014-08-07 02:10:13 UTC) #18
mshelley
The CQ bit was checked by mshelley@chromium.org
6 years, 4 months ago (2014-08-07 02:57:01 UTC) #19
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/mshelley@chromium.org/416683002/280001
6 years, 4 months ago (2014-08-07 03:00:58 UTC) #20
commit-bot: I haz the power
Change committed as 288024
6 years, 4 months ago (2014-08-07 10:07:27 UTC) #21
wtc
6 years, 4 months ago (2014-08-07 20:04:05 UTC) #22
Message was sent while issue was closed.
Patch set 7 LGTM. Please create a new CL to make the the suggested changes.
Thanks.

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
File net/socket/ssl_client_socket_openssl.cc (right):

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
net/socket/ssl_client_socket_openssl.cc:685: int /*unused*/) {

The second parameter should be named "type". The third parameter should be named
"val".

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
net/socket/ssl_client_socket_openssl.cc:687:
SSLContext::GetInstance()->GetClientSocketFromSSL(ssl);

Move this into the if block because it is only used inside that block.

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
net/socket/ssl_client_socket_openssl.cc:722: BIO_set_callback(ssl_bio,
&SSLClientSocketOpenSSL::BIOCallback);

Nit: Could you delete "SSLClientSocketOpenSSL::" ?

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
net/socket/ssl_client_socket_openssl.cc:1589: // Determines if the session for
|ssl_| is in the cache, and calls the

"the session for |ssl_| is in the cache" is not true if the server returns an
empty session ID in ServerHello. So this comment isn't accurate. I guess we can
say:

  // Determines if both the handshake and certificate verification have
completed successfully, and and calls the handshake completion callback if that
is the case.

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
net/socket/ssl_client_socket_openssl.cc:1597: void
SSLClientSocketOpenSSL::CheckIfHandshakeFinished() {

Nit: to match the declaration order in the .h file, this method should be
defined after BIOCallback.

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
File net/socket/ssl_client_socket_openssl.h (right):

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
net/socket/ssl_client_socket_openssl.h:109: // Callback that is run by OpenSSL
to obtain information about the

obtain => "report" or "provide"

Alternatively, say:

  // Callback that is used to obtain information about the state of the SSL
handshake.

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
net/socket/ssl_client_socket_openssl.h:111: static void InfoCallback(const SSL*
ssl, int result, int unused);

The second parameter should be named "type". The third parameter should be named
"val". These parameter names come from the OpenSSL source code.

Note: The OpenSSL man page uses different parameter names:
https://www.openssl.org/docs/ssl/SSL_CTX_set_info_callback.html

  The callback function is called as callback(SSL *ssl, int where, int ret).

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
net/socket/ssl_client_socket_openssl.h:170: static long BIOCallback(BIO *bio,

Nit: I suggest moving the InfoCallback function here, so that our OpenSSL
callback functions are declared together. Make the corresponding change to the
.cc file.

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
net/socket/ssl_client_socket_openssl.h:218: bool completed_handshake_;

Hmmm... I wonder if the comment on line 214 and this bool member should be
updated to avoid confusion with the new handshake finished code.

I suggest changing the comment to say:

  // Set when Connect finishes.

and renaming the bool member

  bool completed_connect_;

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
net/socket/ssl_client_socket_openssl.h:278: bool
ran_handshake_finished_callback_;

Nit: this data member name is a little confusing because the callback is now
named "InfoCallback".

We should rename this data member, but I can't come up with a good name. Perhaps
"handshake_succeeded"?

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
net/socket/ssl_client_socket_openssl.h:280: // connection's SSL session.

Nit: shorten "this socket's connection's SSL session" to "this socket's SSL
session".

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
File net/socket/ssl_client_socket_unittest.cc (left):

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
net/socket/ssl_client_socket_unittest.cc:2725: LOG(ERROR) << "SSL Socket
prematurely connected";

Did you mean to delete this? (I agree it's not useful).

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
File net/socket/ssl_client_socket_unittest.cc (right):

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
net/socket/ssl_client_socket_unittest.cc:2697: SpawnedTestServer::SSLOptions
ssl_options;

Delete this line. The |ssl_options| local variable is not used.

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_client_s...
net/socket/ssl_client_socket_unittest.cc:2732: // that do not cache their
session.

Nit: this should point out it is the server that doesn't cache sessions.
Something like:

  // Tests that the completion callback is run with a server that doesn't cache
sessions.

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_session_...
File net/socket/ssl_session_cache_openssl.cc (right):

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_session_...
net/socket/ssl_session_cache_openssl.cc:13: #include "base/callback.h"

Delete this.

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_session_...
File net/socket/ssl_session_cache_openssl.h (right):

https://codereview.chromium.org/416683002/diff/280001/net/socket/ssl_session_...
net/socket/ssl_session_cache_openssl.h:11: #include "base/callback_forward.h"

Delete this.

https://codereview.chromium.org/416683002/diff/280001/net/test/spawned_test_s...
File net/test/spawned_test_server/base_test_server.h (right):

https://codereview.chromium.org/416683002/diff/280001/net/test/spawned_test_s...
net/test/spawned_test_server/base_test_server.h:208: // disabled, the server
will generate a new Session ID for every connection.

Hmm... "generate a new session ID" is not the behavior we want to test. What we
want to test is that the server returns an empty session ID in ServerHello.

I checked the tlslite/tls_connection.py code. It seems that if 'sessionCache' is
'None', it generates an empty session ID for ServerHello:

        # Create the ServerHello message
        if sessionCache:
            sessionID = getRandomBytes(32)
        else:
            sessionID = bytearray(0)

So I think this comment should be corrected.

Powered by Google App Engine
This is Rietveld 408576698