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

Issue 10916081: Add secure sockets to dart:io (Closed)

Created:
8 years, 3 months ago by Bill Hesse
Modified:
8 years, 1 month ago
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Add a TlsSocket class to dart:io, that implements secure client sockets using TLS (SSL). This uses the NSS (Network Security Services) libraries from Mozilla, which is a cross-platform library for SSL and TLS sockets. We use the patched version from the Chromium repository, which is checked into third_party by the DEPS file. Committed: https://code.google.com/p/dart/source/detail?r=14893

Patch Set 1 #

Patch Set 2 : Working secure socket connection. #

Patch Set 3 : Rebase to TOT #

Patch Set 4 : Make it work on MacOS. #

Patch Set 5 : Unify platforms. #

Patch Set 6 : Remove platform-dependent files. #

Patch Set 7 : Unify platforms #

Patch Set 8 : Add Mac OS changes. #

Patch Set 9 : Allow TLS sockets to build with both Chromium NSS and upstream NSS #

Total comments: 50

Patch Set 10 : Remove support for vanilla NSS #

Patch Set 11 : Fix Windows 32-bit compilation, move pkcert directory to test directory. #

Patch Set 12 : Remove pkcert directory temporarily from patch, because git cl patch is incompatible. #

Total comments: 2

Patch Set 13 : Switch to system of patched libraries in dart:io for new TlsSocket class. #

Total comments: 4

Patch Set 14 : Address comments #

Patch Set 15 : Fix typo in bin.gypi #

Total comments: 35

Patch Set 16 : Add tls_socket.dart to lib/io. #

Patch Set 17 : Address comments (done). #

Total comments: 34

Patch Set 18 : Address comments #

Patch Set 19 : Fixes for utf-16 rebase. #

Patch Set 20 : Rebase and fix indentation. #

Patch Set 21 : Move added file because of sdk reorganization. #

Patch Set 22 : Rebase to landed NSS build. #

Patch Set 23 : Pass hostname to implementation from Dart. Remove logging. Remove PlatformData class. Separate c… #

Patch Set 24 : Address comments. #

Patch Set 25 : Create interface TlsFilter, patched with implementation _TlsFilter. #

Total comments: 2

Patch Set 26 : Fix patch for dart2js dart:io lib. #

Patch Set 27 : Remove some magic numbers, edit TODOs. #

Total comments: 81

Patch Set 28 : Address comments. #

Patch Set 29 : Throw exceptions from errors in TlsSocket, instead of printing messages. #

Patch Set 30 : Add Socket.read and pass port number to NSS. #

Total comments: 1

Patch Set 31 : Make NSS library initialization thread-safe. #

Patch Set 32 : Address comments. #

Total comments: 25

Patch Set 33 : Address comments, remove HandshakeStartHandler. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1636 lines, -24 lines) Patch
M runtime/bin/bin.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3 chunks +3 lines, -3 lines 0 comments Download
M runtime/bin/dartutils.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 2 chunks +22 lines, -1 line 0 comments Download
M runtime/bin/dartutils.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 2 chunks +39 lines, -13 lines 0 comments Download
M runtime/bin/file.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +0 lines, -7 lines 0 comments Download
M runtime/bin/io_impl_sources.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 chunks +4 lines, -0 lines 0 comments Download
M runtime/bin/io_natives.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 1 chunk +8 lines, -2 lines 0 comments Download
M runtime/bin/io_sources.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -0 lines 0 comments Download
A runtime/bin/net/nss_memio.h View 1 2 3 4 5 6 7 1 chunk +90 lines, -0 lines 0 comments Download
A runtime/bin/net/nss_memio.cc View 1 2 3 4 5 6 7 1 chunk +491 lines, -0 lines 0 comments Download
A runtime/bin/tls_socket.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 1 chunk +101 lines, -0 lines 0 comments Download
A runtime/bin/tls_socket.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 1 chunk +385 lines, -0 lines 0 comments Download
A runtime/bin/tls_socket_patch.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 1 chunk +52 lines, -0 lines 0 comments Download
M runtime/bin/utils.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 chunk +1 line, -0 lines 0 comments Download
M sdk/lib/_internal/compiler/implementation/lib/io_patch.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 1 chunk +12 lines, -0 lines 0 comments Download
M sdk/lib/io/iolib_sources.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +1 line, -0 lines 0 comments Download
A sdk/lib/io/tls_socket.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 1 chunk +373 lines, -0 lines 0 comments Download
A tests/standalone/io/pkcert/cert9.db View 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 0 chunks +-1 lines, --1 lines 0 comments Download
A tests/standalone/io/pkcert/key4.db View 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 0 chunks +-1 lines, --1 lines 0 comments Download
A tests/standalone/io/pkcert/pkcs11.txt View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 1 chunk +5 lines, -0 lines 0 comments Download
A tests/standalone/io/tls_socket_test.dart View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 chunk +50 lines, -0 lines 0 comments Download

Messages

Total messages: 17 (0 generated)
Bill Hesse
No hurry - this is working, but not cleaned up yet. Feel free to comment, ...
8 years, 2 months ago (2012-09-27 13:39:21 UTC) #1
Søren Gjesse
Some initial build related comments. http://codereview.chromium.org/10916081/diff/17001/runtime/bin/bin.gypi File runtime/bin/bin.gypi (right): http://codereview.chromium.org/10916081/diff/17001/runtime/bin/bin.gypi#newcode7 runtime/bin/bin.gypi:7: 'use_chromium_nss': 1, Please add ...
8 years, 2 months ago (2012-09-28 09:17:30 UTC) #2
Mads Ager (google)
I couple of initial C++ cleanup comments. Ping on the issue again when this has ...
8 years, 2 months ago (2012-09-28 12:03:56 UTC) #3
Bill Hesse
Comments addressed, much cleanup and refactoring done. Most of TlsSocket's implementation moved to lib/io. Ready ...
8 years, 1 month ago (2012-10-31 16:33:28 UTC) #4
Anders Johnsen
There is quite a bit of debug info there still. First very small round of ...
8 years, 1 month ago (2012-11-01 07:27:21 UTC) #5
Mads Ager (google)
First round of comments. http://codereview.chromium.org/10916081/diff/43003/lib/io/tls_socket.dart File lib/io/tls_socket.dart (right): http://codereview.chromium.org/10916081/diff/43003/lib/io/tls_socket.dart#newcode23 lib/io/tls_socket.dart:23: static final int _BUFFER_SIZE = ...
8 years, 1 month ago (2012-11-01 10:09:01 UTC) #6
Søren Gjesse
https://codereview.chromium.org/10916081/diff/43001/runtime/bin/dartutils.cc File runtime/bin/dartutils.cc (right): https://codereview.chromium.org/10916081/diff/43001/runtime/bin/dartutils.cc#newcode488 runtime/bin/dartutils.cc:488: return Dart_GetClass(Dart_LookupLibrary(Dart_NewString(library_url)), Does this work correctly with error handles ...
8 years, 1 month ago (2012-11-01 11:49:11 UTC) #7
Bill Hesse
Cleaned up and read over. PTAL. http://codereview.chromium.org/10916081/diff/43001/runtime/bin/dartutils.cc File runtime/bin/dartutils.cc (right): http://codereview.chromium.org/10916081/diff/43001/runtime/bin/dartutils.cc#newcode488 runtime/bin/dartutils.cc:488: return Dart_GetClass(Dart_LookupLibrary(Dart_NewString(library_url)), On ...
8 years, 1 month ago (2012-11-11 22:34:34 UTC) #8
Mads Ager (google)
http://codereview.chromium.org/10916081/diff/43003/lib/io/tls_socket.dart File lib/io/tls_socket.dart (right): http://codereview.chromium.org/10916081/diff/43003/lib/io/tls_socket.dart#newcode32 lib/io/tls_socket.dart:32: static final int kReadPlaintext = 0; > On 2012/11/01 ...
8 years, 1 month ago (2012-11-12 11:39:07 UTC) #9
Søren Gjesse
http://codereview.chromium.org/10916081/diff/51003/runtime/bin/tls_socket.cc File runtime/bin/tls_socket.cc (right): http://codereview.chromium.org/10916081/diff/51003/runtime/bin/tls_socket.cc#newcode162 runtime/bin/tls_socket.cc:162: Dart_Handle tls_external_buffer_class = ThrowIfError( Wouldn't it be simpler to ...
8 years, 1 month ago (2012-11-12 12:04:56 UTC) #10
Bill Hesse
I think this is looking much nicer, due to comments and cleanup. Please take a ...
8 years, 1 month ago (2012-11-13 20:11:07 UTC) #11
Søren Gjesse
LGTM! http://codereview.chromium.org/10916081/diff/41025/runtime/bin/tls_socket.cc File runtime/bin/tls_socket.cc (right): http://codereview.chromium.org/10916081/diff/41025/runtime/bin/tls_socket.cc#newcode56 runtime/bin/tls_socket.cc:56: TlsFilter* filter = new TlsFilter; Move the creation ...
8 years, 1 month ago (2012-11-14 08:18:59 UTC) #12
Mads Ager (google)
LGTM with the comments addressed. https://codereview.chromium.org/10916081/diff/51003/runtime/bin/tls_socket.cc File runtime/bin/tls_socket.cc (right): https://codereview.chromium.org/10916081/diff/51003/runtime/bin/tls_socket.cc#newcode256 runtime/bin/tls_socket.cc:256: void TlsFilter::Handshake() { On ...
8 years, 1 month ago (2012-11-14 10:18:53 UTC) #13
Bill Hesse
All comments addressed. https://codereview.chromium.org/10916081/diff/51003/runtime/bin/tls_socket.cc File runtime/bin/tls_socket.cc (right): https://codereview.chromium.org/10916081/diff/51003/runtime/bin/tls_socket.cc#newcode256 runtime/bin/tls_socket.cc:256: void TlsFilter::Handshake() { On 2012/11/14 10:18:54, ...
8 years, 1 month ago (2012-11-14 13:33:29 UTC) #14
Søren Gjesse
https://codereview.chromium.org/10916081/diff/41025/runtime/bin/tls_socket.cc File runtime/bin/tls_socket.cc (right): https://codereview.chromium.org/10916081/diff/41025/runtime/bin/tls_socket.cc#newcode188 runtime/bin/tls_socket.cc:188: Dart_NewExternalByteArray(buffers_[i], buffer_size_, NULL, NULL)); On 2012/11/14 13:33:30, Bill Hesse ...
8 years, 1 month ago (2012-11-14 13:43:11 UTC) #15
Bill Hesse
https://codereview.chromium.org/10916081/diff/41025/runtime/bin/tls_socket.cc File runtime/bin/tls_socket.cc (right): https://codereview.chromium.org/10916081/diff/41025/runtime/bin/tls_socket.cc#newcode188 runtime/bin/tls_socket.cc:188: Dart_NewExternalByteArray(buffers_[i], buffer_size_, NULL, NULL)); On 2012/11/14 13:43:12, Søren Gjesse ...
8 years, 1 month ago (2012-11-14 16:06:46 UTC) #16
Bob Nystrom
8 years, 1 month ago (2012-11-14 18:06:36 UTC) #17
http://codereview.chromium.org/10916081/diff/43003/lib/io/tls_socket.dart
File lib/io/tls_socket.dart (right):

http://codereview.chromium.org/10916081/diff/43003/lib/io/tls_socket.dart#new...
lib/io/tls_socket.dart:32: static final int kReadPlaintext = 0;
On 2012/11/12 11:39:08, Mads Ager wrote:
> > On 2012/11/01 10:09:01, Mads Ager wrote:
> > > This is using a different naming style than the other constants.
> > >
> On 2012/11/11 22:34:34, Bill Hesse wrote:
> > Should we be consistent?  Which do you prefer?
> > It does seem like the states are like enum constants, while the k-constants
> are
> > actual values.
> 
> Of course we should be consistent!
> 
> The are all just 'static final int' and we have a naming convention for those.
> In the rest of dart:io we have been using UPPER_CASE for all of these. Please
do
> so here as well. These are all constants and therefore use the same naming
> convention.
> 

Style nit. These are technically not constants, they're finals. Either of the
following would be OK according to the style guide:

static const READ_PLAINTEXT = 0;
static final readPlaintext = 0;

If it's "conceptually constant" but not an actual const declaration, it should
be camelCase without any prefix.

The idea here is that this way users of a library can tell which things can be
used in their own constant expressions and which cannot. If you were to name
this READ_PLAINTEXT but leave it static final, it would confuse users who then
get an error in something like const [READ_PLAINTEXT].

Powered by Google App Engine
This is Rietveld 408576698