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 // VMOptions= | 5 // VMOptions= |
6 // VMOptions=--short_socket_read | 6 // VMOptions=--short_socket_read |
7 // VMOptions=--short_socket_write | 7 // VMOptions=--short_socket_write |
8 // VMOptions=--short_socket_read --short_socket_write | 8 // VMOptions=--short_socket_read --short_socket_write |
9 | 9 |
10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
11 import "package:path/path.dart"; | 11 import "package:path/path.dart"; |
12 import "dart:async"; | 12 import "dart:async"; |
13 import "dart:io"; | 13 import "dart:io"; |
14 | 14 |
15 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 15 String localFile(path) => Platform.script.resolve(path).toFilePath(); |
| 16 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync(); |
16 | 17 |
17 SecurityContext serverContext = new SecurityContext() | 18 SecurityContext serverContext = new SecurityContext() |
18 ..useCertificateChain(localFile('certificates/server_chain.pem')) | 19 ..useCertificateChain(localFile('certificates/server_chain.pem')) |
19 ..usePrivateKey(localFile('certificates/server_key.pem'), | 20 ..usePrivateKeyAsBytes(readLocalFile('certificates/server_key.pem'), |
20 password: 'dartdart'); | 21 password: 'dartdart'); |
21 | 22 |
22 SecurityContext clientContext = new SecurityContext() | 23 SecurityContext clientContext = new SecurityContext() |
23 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); | 24 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); |
24 | 25 |
25 Future<HttpServer> startServer() { | 26 Future<HttpServer> startServer() { |
26 return HttpServer.bindSecure( | 27 return HttpServer.bindSecure( |
27 "localhost", | 28 "localhost", |
28 0, | 29 0, |
29 serverContext, | 30 serverContext, |
30 backlog: 5).then((server) { | 31 backlog: 5).then((server) { |
(...skipping 30 matching lines...) Expand all Loading... |
61 server.close(); | 62 server.close(); |
62 }, | 63 }, |
63 onError: (e, trace) { | 64 onError: (e, trace) { |
64 String msg = "Unexpected error $e"; | 65 String msg = "Unexpected error $e"; |
65 if (trace != null) msg += "\nStackTrace: $trace"; | 66 if (trace != null) msg += "\nStackTrace: $trace"; |
66 Expect.fail(msg); | 67 Expect.fail(msg); |
67 }); | 68 }); |
68 }); | 69 }); |
69 }); | 70 }); |
70 } | 71 } |
OLD | NEW |