OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import "dart:async"; | 5 import "dart:async"; |
6 import "dart:io"; | 6 import "dart:io"; |
7 import "dart:isolate"; | 7 import "dart:isolate"; |
8 | 8 |
9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
10 | 10 |
11 InternetAddress HOST; | 11 InternetAddress HOST; |
12 | 12 |
13 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 13 String localFile(path) => Platform.script.resolve(path).toFilePath(); |
14 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync(); | 14 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync(); |
15 | 15 |
16 SecurityContext serverContext = new SecurityContext() | 16 SecurityContext serverContext = new SecurityContext() |
17 ..useCertificateChainBytes(readLocalFile('certificates/server_chain.pem')) | 17 ..useCertificateChainBytes(readLocalFile('certificates/server_chain.pem')) |
18 ..usePrivateKeyBytes(readLocalFile('certificates/server_key.pem'), | 18 ..usePrivateKeyBytes(readLocalFile('certificates/server_key.pem'), |
19 password: 'dartdart'); | 19 password: 'dartdart'); |
20 | 20 |
21 SecurityContext clientContext = new SecurityContext() | 21 SecurityContext clientContext = new SecurityContext() |
22 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); | 22 ..setTrustedCertificatesBytes( |
| 23 readLocalFile('certificates/trusted_certs.pem')); |
23 | 24 |
24 void testListenOn() { | 25 void testListenOn() { |
25 void test(void onDone()) { | 26 void test(void onDone()) { |
26 HttpServer.bindSecure(HOST, | 27 HttpServer.bindSecure(HOST, |
27 0, | 28 0, |
28 serverContext, | 29 serverContext, |
29 backlog: 5).then((server) { | 30 backlog: 5).then((server) { |
30 ReceivePort serverPort = new ReceivePort(); | 31 ReceivePort serverPort = new ReceivePort(); |
31 server.listen((HttpRequest request) { | 32 server.listen((HttpRequest request) { |
32 request.listen( | 33 request.listen( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 }); | 100 }); |
100 } | 101 } |
101 | 102 |
102 void main() { | 103 void main() { |
103 InternetAddress.lookup("localhost").then((hosts) { | 104 InternetAddress.lookup("localhost").then((hosts) { |
104 HOST = hosts.first; | 105 HOST = hosts.first; |
105 testListenOn(); | 106 testListenOn(); |
106 testEarlyClientClose(); | 107 testEarlyClientClose(); |
107 }); | 108 }); |
108 } | 109 } |
OLD | NEW |