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

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

Issue 1665433002: Adds SecurityContext.setTrustedCertificatesBytes (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Adds MemBIOScope 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 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 8 // VMOptions=--short_socket_read --short_socket_write
9 9
10 import "dart:async"; 10 import "dart:async";
11 import "dart:io"; 11 import "dart:io";
12 12
13 import "package:async_helper/async_helper.dart"; 13 import "package:async_helper/async_helper.dart";
14 import "package:expect/expect.dart"; 14 import "package:expect/expect.dart";
15 15
16 String localFile(path) => Platform.script.resolve(path).toFilePath(); 16 String localFile(path) => Platform.script.resolve(path).toFilePath();
17 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync(); 17 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync();
18 18
19 SecurityContext serverContext = new SecurityContext() 19 SecurityContext serverContext = new SecurityContext()
20 ..useCertificateChainBytes(readLocalFile('certificates/server_chain.pem')) 20 ..useCertificateChainBytes(readLocalFile('certificates/server_chain.pem'))
21 ..usePrivateKeyBytes(readLocalFile('certificates/server_key.pem'), 21 ..usePrivateKeyBytes(readLocalFile('certificates/server_key.pem'),
22 password: 'dartdart'); 22 password: 'dartdart');
23 23
24 SecurityContext clientContext = new SecurityContext() 24 SecurityContext clientContext = new SecurityContext()
25 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); 25 ..setTrustedCertificatesBytes(
26 readLocalFile('certificates/trusted_certs.pem'));
26 27
27 InternetAddress HOST; 28 InternetAddress HOST;
28 Future<RawSecureServerSocket> startEchoServer() { 29 Future<RawSecureServerSocket> startEchoServer() {
29 return RawSecureServerSocket.bind(HOST, 30 return RawSecureServerSocket.bind(HOST,
30 0, 31 0,
31 serverContext).then((server) { 32 serverContext).then((server) {
32 server.listen((RawSecureSocket client) { 33 server.listen((RawSecureSocket client) {
33 List<List<int>> readChunks = <List<int>>[]; 34 List<List<int>> readChunks = <List<int>>[];
34 List<int> dataToWrite = null; 35 List<int> dataToWrite = null;
35 int bytesWritten = 0; 36 int bytesWritten = 0;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 90 }
90 91
91 void main() { 92 void main() {
92 asyncStart(); 93 asyncStart();
93 InternetAddress.lookup("localhost").then((hosts) => HOST = hosts.first) 94 InternetAddress.lookup("localhost").then((hosts) => HOST = hosts.first)
94 .then((_) => startEchoServer()) 95 .then((_) => startEchoServer())
95 .then(testClient) 96 .then(testClient)
96 .then((server) => server.close()) 97 .then((server) => server.close())
97 .then((_) => asyncEnd()); 98 .then((_) => asyncEnd());
98 } 99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698