| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 // This test verifies that a server certificate can be verified by a client | |
| 6 // that loads the certificate authority certificate it depends on at runtime. | |
| 7 | |
| 8 import "package:path/path.dart"; | |
| 9 import "dart:io"; | |
| 10 import "dart:async"; | |
| 11 | |
| 12 String scriptDir = dirname(new Options().script); | |
| 13 | |
| 14 void main() { | |
| 15 SecureSocket.initialize(database: join(scriptDir, 'pkcert'), | |
| 16 password: 'dartdart'); | |
| 17 runServer().then((SecureServerSocket server) { | |
| 18 return Process.run(new Options().executable, | |
| 19 ['--checked', | |
| 20 join(scriptDir, 'certificate_test_client.dart'), | |
| 21 server.port.toString(), | |
| 22 join(scriptDir, 'pkcert', 'myauthority.pem')]); | |
| 23 }).then((ProcessResult result) { | |
| 24 if (result.exitCode != 0 || !result.stdout.contains("SUCCESS")) { | |
| 25 print("Client failed with exit code ${result.exitCode}"); | |
| 26 print(" stdout (expects \"SUCCESS\\n\"):"); | |
| 27 print(result.stdout); | |
| 28 print(" stderr:"); | |
| 29 print(result.stderr); | |
| 30 throw new AssertionError(); | |
| 31 } | |
| 32 }); | |
| 33 } | |
| 34 | |
| 35 Future<SecureServerSocket> runServer() => | |
| 36 SecureServerSocket.bind("localhost", 0, "localhost_cert") | |
| 37 .then((server) => server..listen( | |
| 38 (socket) => socket.pipe(socket).then((_) => server.close()))); | |
| OLD | NEW |