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:uri"; | 7 import "dart:uri"; |
8 import "dart:isolate"; | 8 import "dart:isolate"; |
9 | 9 |
10 const SERVER_ADDRESS = "127.0.0.1"; | 10 const SERVER_ADDRESS = "127.0.0.1"; |
(...skipping 29 matching lines...) Expand all Loading... |
40 backlog: 5, | 40 backlog: 5, |
41 certificate_name: 'CN=$HOST_NAME', | 41 certificate_name: 'CN=$HOST_NAME', |
42 requestClientCertificate: true); | 42 requestClientCertificate: true); |
43 | 43 |
44 HttpClient client = new HttpClient(); | 44 HttpClient client = new HttpClient(); |
45 Future testConnect(bool sendCertificate) { | 45 Future testConnect(bool sendCertificate) { |
46 client.sendClientCertificate = sendCertificate; | 46 client.sendClientCertificate = sendCertificate; |
47 client.clientCertificate = options['certificateName']; | 47 client.clientCertificate = options['certificateName']; |
48 var completer = new Completer(); | 48 var completer = new Completer(); |
49 HttpClientConnection conn = | 49 HttpClientConnection conn = |
50 client.getUrl(new Uri.fromString( | 50 client.getUrl(Uri.parse( |
51 "https://$HOST_NAME:${server.port}/$sendCertificate")); | 51 "https://$HOST_NAME:${server.port}/$sendCertificate")); |
52 conn.onRequest = (HttpClientRequest request) { | 52 conn.onRequest = (HttpClientRequest request) { |
53 request.outputStream.close(); | 53 request.outputStream.close(); |
54 }; | 54 }; |
55 conn.onResponse = (HttpClientResponse response) { | 55 conn.onResponse = (HttpClientResponse response) { |
56 Expect.isNotNull(response.certificate); | 56 Expect.isNotNull(response.certificate); |
57 Expect.equals('CN=myauthority', response.certificate.issuer); | 57 Expect.equals('CN=myauthority', response.certificate.issuer); |
58 response.inputStream.onClosed = () { | 58 response.inputStream.onClosed = () { |
59 completer.complete(false); // Chained call will not send cert. | 59 completer.complete(false); // Chained call will not send cert. |
60 }; | 60 }; |
(...skipping 27 matching lines...) Expand all Loading... |
88 var keepAlive = new ReceivePort(); | 88 var keepAlive = new ReceivePort(); |
89 InitializeSSL(); | 89 InitializeSSL(); |
90 // Test two connections in sequence. | 90 // Test two connections in sequence. |
91 test({'certificateName': null})() | 91 test({'certificateName': null})() |
92 .then((_) => test({'certificateName': 'localhost_cert'})()) | 92 .then((_) => test({'certificateName': 'localhost_cert'})()) |
93 .then((_) { | 93 .then((_) { |
94 Expect.equals(2, numClientCertificatesReceived); | 94 Expect.equals(2, numClientCertificatesReceived); |
95 keepAlive.close(); | 95 keepAlive.close(); |
96 }); | 96 }); |
97 } | 97 } |
OLD | NEW |