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 // Client for secure_socket_renegotiate_test, that runs in a subprocess. | 5 // Client for secure_socket_renegotiate_test, that runs in a subprocess. |
6 // The test verifies that client certificates work, if the client and server | 6 // The test verifies that client certificates work, if the client and server |
7 // are in separate processes, and that connection renegotiation can request | 7 // are in separate processes, and that connection renegotiation can request |
8 // a client certificate to be sent. | 8 // a client certificate to be sent. |
9 | 9 |
10 import "dart:async"; | 10 import "dart:async"; |
(...skipping 23 matching lines...) Expand all Loading... |
34 void expect(condition) { | 34 void expect(condition) { |
35 if (!condition) { | 35 if (!condition) { |
36 throw new ExpectException(''); | 36 throw new ExpectException(''); |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 | 40 |
41 void runClient(int port) { | 41 void runClient(int port) { |
42 SecureSocket.connect(HOST_NAME, | 42 SecureSocket.connect(HOST_NAME, |
43 port, | 43 port, |
44 context: clientContext, | 44 context: clientContext) |
45 sendClientCertificate: true) | |
46 .then((SecureSocket socket) { | 45 .then((SecureSocket socket) { |
47 X509Certificate certificate = socket.peerCertificate; | 46 X509Certificate certificate = socket.peerCertificate; |
48 expect(certificate != null); | 47 expect(certificate != null); |
49 expectEquals('CN=localhost', certificate.subject); | 48 expectEquals('CN=localhost', certificate.subject); |
50 expectEquals('CN=myauthority', certificate.issuer); | 49 expectEquals('CN=myauthority', certificate.issuer); |
51 StreamIterator<String> input = new StreamIterator(socket | 50 StreamIterator<String> input = new StreamIterator(socket |
52 .transform(UTF8.decoder) | 51 .transform(UTF8.decoder) |
53 .transform(new LineSplitter())); | 52 .transform(new LineSplitter())); |
54 socket.writeln('first'); | 53 socket.writeln('first'); |
55 input.moveNext() | 54 input.moveNext() |
(...skipping 18 matching lines...) Expand all Loading... |
74 expect(success != true); | 73 expect(success != true); |
75 socket.close(); | 74 socket.close(); |
76 }); | 75 }); |
77 }); | 76 }); |
78 } | 77 } |
79 | 78 |
80 | 79 |
81 void main(List<String> args) { | 80 void main(List<String> args) { |
82 runClient(int.parse(args[0])); | 81 runClient(int.parse(args[0])); |
83 } | 82 } |
OLD | NEW |