| 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:async_helper/async_helper.dart"; | 10 import "package:async_helper/async_helper.dart"; |
| 11 import "package:expect/expect.dart"; | 11 import "package:expect/expect.dart"; |
| 12 import "package:path/path.dart"; | 12 import "package:path/path.dart"; |
| 13 import "dart:async"; | 13 import "dart:async"; |
| 14 import "dart:io"; | 14 import "dart:io"; |
| 15 | 15 |
| 16 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 16 String localFile(path) => Platform.script.resolve(path).toFilePath(); |
| 17 | 17 |
| 18 SecurityContext serverContext(String certType, String password) => | 18 SecurityContext serverContext(String certType, String password) => |
| 19 new SecurityContext() | 19 new SecurityContext() |
| 20 ..useCertificateChainSync(localFile('certificates/server_chain.$certType'), | 20 ..useCertificateChain(localFile('certificates/server_chain.$certType'), |
| 21 password: password) | 21 password: password) |
| 22 ..usePrivateKeySync(localFile('certificates/server_key.$certType'), | 22 ..usePrivateKey(localFile('certificates/server_key.$certType'), |
| 23 password: password); | 23 password: password); |
| 24 | 24 |
| 25 SecurityContext clientContext(String certType, String password) => | 25 SecurityContext clientContext(String certType, String password) => |
| 26 new SecurityContext() | 26 new SecurityContext() |
| 27 ..setTrustedCertificatesSync(localFile( | 27 ..setTrustedCertificates(localFile('certificates/trusted_certs.$certType'), |
| 28 'certificates/trusted_certs.$certType'), password: password); | 28 password: password); |
| 29 | 29 |
| 30 Future<HttpServer> startServer(String certType, String password) { | 30 Future<HttpServer> startServer(String certType, String password) { |
| 31 return HttpServer.bindSecure( | 31 return HttpServer.bindSecure( |
| 32 "localhost", | 32 "localhost", |
| 33 0, | 33 0, |
| 34 serverContext(certType, password), | 34 serverContext(certType, password), |
| 35 backlog: 5).then((server) { | 35 backlog: 5).then((server) { |
| 36 server.listen((HttpRequest request) { | 36 server.listen((HttpRequest request) { |
| 37 request.listen( | 37 request.listen( |
| 38 (_) { }, | 38 (_) { }, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 }); | 74 }); |
| 75 }); | 75 }); |
| 76 } | 76 } |
| 77 | 77 |
| 78 main() async { | 78 main() async { |
| 79 asyncStart(); | 79 asyncStart(); |
| 80 await test('pem', 'dartdart'); | 80 await test('pem', 'dartdart'); |
| 81 await test('p12', 'dartdart'); | 81 await test('p12', 'dartdart'); |
| 82 asyncEnd(); | 82 asyncEnd(); |
| 83 } | 83 } |
| OLD | NEW |