Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: tests/standalone/io/secure_socket_renegotiate_test.dart

Issue 1616073004: Adds SecurityContext.usePrivateKeyBytes (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // This test verifies that client certificates work, if the client and server 5 // This test verifies that client certificates work, if the client and server
6 // are in separate processes, and that connection renegotiation works, and 6 // are in separate processes, and that connection renegotiation works, and
7 // can request a client certificate to be sent. 7 // can request a client certificate to be sent.
8 8
9 import "dart:async"; 9 import "dart:async";
10 import "dart:convert"; 10 import "dart:convert";
11 import "dart:io"; 11 import "dart:io";
12 12
13 import "package:expect/expect.dart"; 13 import "package:expect/expect.dart";
14 import "package:path/path.dart"; 14 import "package:path/path.dart";
15 15
16 const HOST_NAME = "localhost"; 16 const HOST_NAME = "localhost";
17 String localFile(path) => Platform.script.resolve(path).toFilePath(); 17 String localFile(path) => Platform.script.resolve(path).toFilePath();
18 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync();
18 19
19 SecurityContext serverContext = new SecurityContext() 20 SecurityContext serverContext = new SecurityContext()
20 ..useCertificateChain(localFile('certificates/server_chain.pem')) 21 ..useCertificateChain(localFile('certificates/server_chain.pem'))
21 ..usePrivateKey(localFile('certificates/server_key.pem'), 22 ..usePrivateKeyAsBytes(readLocalFile('certificates/server_key.pem'),
22 password: 'dartdart'); 23 password: 'dartdart');
23 24
24 Future<SecureServerSocket> runServer() { 25 Future<SecureServerSocket> runServer() {
25 return SecureServerSocket.bind(HOST_NAME, 0, serverContext) 26 return SecureServerSocket.bind(HOST_NAME, 0, serverContext)
26 .then((SecureServerSocket server) { 27 .then((SecureServerSocket server) {
27 server.listen((SecureSocket socket) { 28 server.listen((SecureSocket socket) {
28 Expect.isNull(socket.peerCertificate); 29 Expect.isNull(socket.peerCertificate);
29 30
30 StreamIterator<String> input = 31 StreamIterator<String> input =
31 new StreamIterator(socket.transform(UTF8.decoder) 32 new StreamIterator(socket.transform(UTF8.decoder)
32 .transform(new LineSplitter())); 33 .transform(new LineSplitter()));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 if (result.exitCode != 0) { 75 if (result.exitCode != 0) {
75 print("Client failed, stdout:"); 76 print("Client failed, stdout:");
76 print(result.stdout); 77 print(result.stdout);
77 print(" stderr:"); 78 print(" stderr:");
78 print(result.stderr); 79 print(result.stderr);
79 Expect.fail('Client subprocess exit code: ${result.exitCode}'); 80 Expect.fail('Client subprocess exit code: ${result.exitCode}');
80 } 81 }
81 }); 82 });
82 }); 83 });
83 } 84 }
OLDNEW
« no previous file with comments | « tests/standalone/io/secure_socket_alpn_test.dart ('k') | tests/standalone/io/secure_socket_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698