OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // | 4 // |
5 // This test tests TLS session resume, by making multiple client connections | 5 // This test tests TLS session resume, by making multiple client connections |
6 // on the same port to the same server, with a delay of 200 ms between them. | 6 // on the same port to the same server, with a delay of 200 ms between them. |
7 // The unmodified secure_server_test creates all sessions simultaneously, | 7 // The unmodified secure_server_test creates all sessions simultaneously, |
8 // which means that no handshake completes and caches its keys in the session | 8 // which means that no handshake completes and caches its keys in the session |
9 // cache in time for other connections to use it. | 9 // cache in time for other connections to use it. |
10 // | 10 // |
(...skipping 10 matching lines...) Expand all Loading... |
21 import "dart:isolate"; | 21 import "dart:isolate"; |
22 | 22 |
23 import "package:expect/expect.dart"; | 23 import "package:expect/expect.dart"; |
24 import "package:async_helper/async_helper.dart"; | 24 import "package:async_helper/async_helper.dart"; |
25 | 25 |
26 InternetAddress HOST; | 26 InternetAddress HOST; |
27 | 27 |
28 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 28 String localFile(path) => Platform.script.resolve(path).toFilePath(); |
29 | 29 |
30 SecurityContext serverContext = new SecurityContext() | 30 SecurityContext serverContext = new SecurityContext() |
31 ..useCertificateChainSync(localFile('certificates/server_chain.pem')) | 31 ..useCertificateChain(localFile('certificates/server_chain.pem')) |
32 ..usePrivateKeySync(localFile('certificates/server_key.pem'), | 32 ..usePrivateKey(localFile('certificates/server_key.pem'), |
33 password: 'dartdart'); | 33 password: 'dartdart'); |
34 | 34 |
35 SecurityContext clientContext = new SecurityContext() | 35 SecurityContext clientContext = new SecurityContext() |
36 ..setTrustedCertificatesSync(localFile('certificates/trusted_certs.pem')); | 36 ..setTrustedCertificates(localFile('certificates/trusted_certs.pem')); |
37 | 37 |
38 Future<SecureServerSocket> startServer() { | 38 Future<SecureServerSocket> startServer() { |
39 return SecureServerSocket.bind(HOST, | 39 return SecureServerSocket.bind(HOST, |
40 0, | 40 0, |
41 serverContext).then((server) { | 41 serverContext).then((server) { |
42 server.listen((SecureSocket client) { | 42 server.listen((SecureSocket client) { |
43 client.fold(<int>[], (message, data) => message..addAll(data)) | 43 client.fold(<int>[], (message, data) => message..addAll(data)) |
44 .then((message) { | 44 .then((message) { |
45 String received = new String.fromCharCodes(message); | 45 String received = new String.fromCharCodes(message); |
46 Expect.isTrue(received.contains("Hello from client ")); | 46 Expect.isTrue(received.contains("Hello from client ")); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 return startServer() | 80 return startServer() |
81 .then((server) => Future.wait( | 81 .then((server) => Future.wait( |
82 ['able', 'baker', 'charlie', 'dozen', 'elapse'] | 82 ['able', 'baker', 'charlie', 'dozen', 'elapse'] |
83 .map((name) { | 83 .map((name) { |
84 delay += delay_between_connections; | 84 delay += delay_between_connections; |
85 return new Future.delayed(delay, () => server) | 85 return new Future.delayed(delay, () => server) |
86 .then((server) => testClient(server, name)); | 86 .then((server) => testClient(server, name)); |
87 }))) | 87 }))) |
88 .then((servers) => servers.first.close()); | 88 .then((servers) => servers.first.close()); |
89 } | 89 } |
OLD | NEW |