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 import "dart:async"; | 5 import "dart:async"; |
6 import "dart:io"; | 6 import "dart:io"; |
7 | 7 |
8 import "package:async_helper/async_helper.dart"; | 8 import "package:async_helper/async_helper.dart"; |
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 ..setTrustedCertificates(file: localFile('certificates/client_authority.pem')) | 20 ..setTrustedCertificates(file: localFile('certificates/client_authority.pem')) |
21 ..setClientAuthorities(localFile('certificates/client_authority.pem')); | 21 ..setClientAuthoritiesBytes( |
| 22 readLocalFile('certificates/client_authority.pem')); |
22 | 23 |
23 SecurityContext clientCertContext = new SecurityContext() | 24 SecurityContext clientCertContext = new SecurityContext() |
24 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')) | 25 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')) |
25 ..useCertificateChainBytes(readLocalFile('certificates/client1.pem')) | 26 ..useCertificateChainBytes(readLocalFile('certificates/client1.pem')) |
26 ..usePrivateKeyBytes(readLocalFile('certificates/client1_key.pem'), | 27 ..usePrivateKeyBytes(readLocalFile('certificates/client1_key.pem'), |
27 password: 'dartdart'); | 28 password: 'dartdart'); |
28 | 29 |
29 SecurityContext clientNoCertContext = new SecurityContext() | 30 SecurityContext clientNoCertContext = new SecurityContext() |
30 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); | 31 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); |
31 | 32 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 69 |
69 main() async { | 70 main() async { |
70 asyncStart(); | 71 asyncStart(); |
71 HOST = (await InternetAddress.lookup("localhost")).first; | 72 HOST = (await InternetAddress.lookup("localhost")).first; |
72 await testClientCertificate(required: false, sendCert: true); | 73 await testClientCertificate(required: false, sendCert: true); |
73 await testClientCertificate(required: true, sendCert: true); | 74 await testClientCertificate(required: true, sendCert: true); |
74 await testClientCertificate(required: false, sendCert: false); | 75 await testClientCertificate(required: false, sendCert: false); |
75 await testClientCertificate(required: true, sendCert: false); | 76 await testClientCertificate(required: true, sendCert: false); |
76 asyncEnd(); | 77 asyncEnd(); |
77 } | 78 } |
OLD | NEW |