Index: tests/standalone/io/secure_client_raw_server_test.dart |
diff --git a/tests/standalone/io/secure_client_raw_server_test.dart b/tests/standalone/io/secure_client_raw_server_test.dart |
index e380f753d0494c74ccdb5aed1277549a097d146a..318edebf570274898888869759270e3caef60978 100644 |
--- a/tests/standalone/io/secure_client_raw_server_test.dart |
+++ b/tests/standalone/io/secure_client_raw_server_test.dart |
@@ -13,12 +13,21 @@ import "dart:io"; |
import "package:async_helper/async_helper.dart"; |
import "package:expect/expect.dart"; |
+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'); |
+ |
+SecurityContext clientContext = new SecurityContext() |
+ ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); |
+ |
InternetAddress HOST; |
-const CERTIFICATE = "localhost_cert"; |
Future<RawSecureServerSocket> startEchoServer() { |
return RawSecureServerSocket.bind(HOST, |
0, |
- CERTIFICATE).then((server) { |
+ serverContext).then((server) { |
server.listen((RawSecureSocket client) { |
List<List<int>> readChunks = <List<int>>[]; |
List<int> dataToWrite = null; |
@@ -60,7 +69,8 @@ Future<RawSecureServerSocket> startEchoServer() { |
Future testClient(server) { |
Completer success = new Completer(); |
List<String> chunks = <String>[]; |
- SecureSocket.connect(HOST, server.port).then((socket) { |
+ SecureSocket.connect(HOST, server.port, context: clientContext) |
+ .then((socket) { |
socket.write("Hello server."); |
socket.close(); |
socket.listen( |
@@ -79,9 +89,6 @@ Future testClient(server) { |
void main() { |
asyncStart(); |
- String certificateDatabase = Platform.script.resolve('pkcert').toFilePath(); |
- SecureSocket.initialize(database: certificateDatabase, |
- password: 'dartdart'); |
InternetAddress.lookup("localhost").then((hosts) => HOST = hosts.first) |
.then((_) => startEchoServer()) |
.then(testClient) |