| 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 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 Expect.fail("Connection succeeded with no required client certificate"); | 61 Expect.fail("Connection succeeded with no required client certificate"); |
| 62 } | 62 } |
| 63 var serverEnd = await server.first; | 63 var serverEnd = await server.first; |
| 64 var clientEnd = await clientEndFuture; | 64 var clientEnd = await clientEndFuture; |
| 65 | 65 |
| 66 X509Certificate clientCertificate = serverEnd.peerCertificate; | 66 X509Certificate clientCertificate = serverEnd.peerCertificate; |
| 67 if (sendCert) { | 67 if (sendCert) { |
| 68 Expect.isNotNull(clientCertificate); | 68 Expect.isNotNull(clientCertificate); |
| 69 Expect.equals("/CN=user1", clientCertificate.subject); | 69 Expect.isTrue(clientCertificate.subject.contains("user1")); |
| 70 Expect.equals("/CN=clientauthority", clientCertificate.issuer); | 70 Expect.isTrue(clientCertificate.issuer.contains("clientauthority")); |
| 71 } else { | 71 } else { |
| 72 Expect.isNull(clientCertificate); | 72 Expect.isNull(clientCertificate); |
| 73 } | 73 } |
| 74 X509Certificate serverCertificate = clientEnd.peerCertificate; | 74 X509Certificate serverCertificate = clientEnd.peerCertificate; |
| 75 Expect.isNotNull(serverCertificate); | 75 Expect.isNotNull(serverCertificate); |
| 76 Expect.equals("/CN=localhost", serverCertificate.subject); | 76 Expect.isTrue(serverCertificate.subject.contains("localhost")); |
| 77 Expect.equals("/CN=intermediateauthority", serverCertificate.issuer); | 77 Expect.isTrue(serverCertificate.issuer.contains("intermediateauthority")); |
| 78 clientEnd.close(); | 78 clientEnd.close(); |
| 79 serverEnd.close(); | 79 serverEnd.close(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 main() async { | 82 main() async { |
| 83 asyncStart(); | 83 asyncStart(); |
| 84 HOST = (await InternetAddress.lookup("localhost")).first; | 84 HOST = (await InternetAddress.lookup("localhost")).first; |
| 85 await testClientCertificate( | 85 await testClientCertificate( |
| 86 required: false, sendCert: true, certType: 'pem', password: 'dartdart'); | 86 required: false, sendCert: true, certType: 'pem', password: 'dartdart'); |
| 87 await testClientCertificate( | 87 await testClientCertificate( |
| 88 required: true, sendCert: true, certType: 'pem', password: 'dartdart'); | 88 required: true, sendCert: true, certType: 'pem', password: 'dartdart'); |
| 89 await testClientCertificate( | 89 await testClientCertificate( |
| 90 required: false, sendCert: false, certType: 'pem', password: 'dartdart'); | 90 required: false, sendCert: false, certType: 'pem', password: 'dartdart'); |
| 91 await testClientCertificate( | 91 await testClientCertificate( |
| 92 required: true, sendCert: false, certType: 'pem', password: 'dartdart'); | 92 required: true, sendCert: false, certType: 'pem', password: 'dartdart'); |
| 93 | 93 |
| 94 await testClientCertificate( | 94 await testClientCertificate( |
| 95 required: false, sendCert: true, certType: 'p12', password: 'dartdart'); | 95 required: false, sendCert: true, certType: 'p12', password: 'dartdart'); |
| 96 await testClientCertificate( | 96 await testClientCertificate( |
| 97 required: true, sendCert: true, certType: 'p12', password: 'dartdart'); | 97 required: true, sendCert: true, certType: 'p12', password: 'dartdart'); |
| 98 await testClientCertificate( | 98 await testClientCertificate( |
| 99 required: false, sendCert: false, certType: 'p12', password: 'dartdart'); | 99 required: false, sendCert: false, certType: 'p12', password: 'dartdart'); |
| 100 await testClientCertificate( | 100 await testClientCertificate( |
| 101 required: true, sendCert: false, certType: 'p12', password: 'dartdart'); | 101 required: true, sendCert: false, certType: 'p12', password: 'dartdart'); |
| 102 asyncEnd(); | 102 asyncEnd(); |
| 103 } | 103 } |
| OLD | NEW |