Index: tests/standalone/io/https_client_certificate_test.dart |
diff --git a/tests/standalone/io/https_client_certificate_test.dart b/tests/standalone/io/https_client_certificate_test.dart |
index f63d383cc0ebf5c6857d133f0ff93ebc1f8d8126..24d397848d4010b518e1eba0593422e45e91dfc6 100644 |
--- a/tests/standalone/io/https_client_certificate_test.dart |
+++ b/tests/standalone/io/https_client_certificate_test.dart |
@@ -10,14 +10,27 @@ import "package:expect/expect.dart"; |
import "package:path/path.dart"; |
const HOST_NAME = "localhost"; |
+String localFile(path) => Platform.script.resolve(path).toFilePath(); |
+SecurityContext serverContext = new SecurityContext() |
+ ..useCertificateChain(localFile('certificates/server_chain.pem')) |
+ ..usePrivateKey(localFile('certificates/server_key.pem'), |
+ password: 'dartdart'); |
+// TODO: Specify which client certificate roots to trust. |
-Function test() { |
+SecurityContext clientContext = new SecurityContext() |
+ ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')) |
+// TODO: Set a client certificate here. |
+ ..useCertificateChain(localFile('certificates/server_chain.pem')) |
+ ..usePrivateKey(localFile('certificates/server_key.pem'), |
+ password: 'dartdart'); |
+ |
+void main() { |
asyncStart(); |
HttpServer.bindSecure(HOST_NAME, |
0, |
+ serverContext, |
backlog: 5, |
- certificateName: 'localhost_cert', |
requestClientCertificate: true).then((server) { |
server.listen((HttpRequest request) { |
Expect.isNotNull(request.certificate); |
@@ -26,7 +39,7 @@ Function test() { |
request.response.close(); |
}); |
- HttpClient client = new HttpClient(); |
+ HttpClient client = new HttpClient(context: clientContext); |
client.getUrl(Uri.parse("https://$HOST_NAME:${server.port}/")) |
.then((request) => request.close()) |
.then((response) { |
@@ -44,14 +57,3 @@ Function test() { |
}); |
}); |
} |
- |
-void InitializeSSL() { |
- var testPkcertDatabase = Platform.script.resolve('pkcert').toFilePath(); |
- SecureSocket.initialize(database: testPkcertDatabase, |
- password: 'dartdart'); |
-} |
- |
-void main() { |
- InitializeSSL(); |
- test(); |
-} |