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 verifies that client certificates work, if the client and server | 5 // This test verifies that client certificates work, if the client and server |
6 // are in separate processes, and that connection renegotiation works, and | 6 // are in separate processes, and that connection renegotiation works, and |
7 // can request a client certificate to be sent. | 7 // can request a client certificate to be sent. |
8 | 8 |
9 import "dart:async"; | 9 import "dart:async"; |
10 import "dart:convert"; | 10 import "dart:convert"; |
11 import "dart:io"; | 11 import "dart:io"; |
12 | 12 |
13 import "package:expect/expect.dart"; | 13 import "package:expect/expect.dart"; |
14 import "package:path/path.dart"; | 14 import "package:path/path.dart"; |
15 | 15 |
16 const HOST_NAME = "localhost"; | 16 const HOST_NAME = "localhost"; |
17 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 17 String localFile(path) => Platform.script.resolve(path).toFilePath(); |
18 | 18 |
19 SecurityContext serverContext = new SecurityContext() | 19 SecurityContext serverContext = new SecurityContext() |
20 ..useCertificateChainSync(localFile('certificates/server_chain.pem')) | 20 ..useCertificateChain(localFile('certificates/server_chain.pem')) |
21 ..usePrivateKeySync(localFile('certificates/server_key.pem'), | 21 ..usePrivateKey(localFile('certificates/server_key.pem'), |
22 password: 'dartdart'); | 22 password: 'dartdart'); |
23 | 23 |
24 Future<SecureServerSocket> runServer() { | 24 Future<SecureServerSocket> runServer() { |
25 return SecureServerSocket.bind(HOST_NAME, 0, serverContext) | 25 return SecureServerSocket.bind(HOST_NAME, 0, serverContext) |
26 .then((SecureServerSocket server) { | 26 .then((SecureServerSocket server) { |
27 server.listen((SecureSocket socket) { | 27 server.listen((SecureSocket socket) { |
28 Expect.isNull(socket.peerCertificate); | 28 Expect.isNull(socket.peerCertificate); |
29 | 29 |
30 StreamIterator<String> input = | 30 StreamIterator<String> input = |
31 new StreamIterator(socket.transform(UTF8.decoder) | 31 new StreamIterator(socket.transform(UTF8.decoder) |
32 .transform(new LineSplitter())); | 32 .transform(new LineSplitter())); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 if (result.exitCode != 0) { | 74 if (result.exitCode != 0) { |
75 print("Client failed, stdout:"); | 75 print("Client failed, stdout:"); |
76 print(result.stdout); | 76 print(result.stdout); |
77 print(" stderr:"); | 77 print(" stderr:"); |
78 print(result.stderr); | 78 print(result.stderr); |
79 Expect.fail('Client subprocess exit code: ${result.exitCode}'); | 79 Expect.fail('Client subprocess exit code: ${result.exitCode}'); |
80 } | 80 } |
81 }); | 81 }); |
82 }); | 82 }); |
83 } | 83 } |
OLD | NEW |