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

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

Issue 1665433002: Adds SecurityContext.setTrustedCertificatesBytes (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
11 import "package:path/path.dart"; 11 import "package:path/path.dart";
12 import "dart:async"; 12 import "dart:async";
13 import "dart:io"; 13 import "dart:io";
14 14
15 String localFile(path) => Platform.script.resolve(path).toFilePath(); 15 String localFile(path) => Platform.script.resolve(path).toFilePath();
16 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync();
17 16
18 SecurityContext serverContext = new SecurityContext() 17 SecurityContext serverContext = new SecurityContext()
19 ..useCertificateChainBytes(readLocalFile('certificates/server_chain.pem')) 18 ..useCertificateChainSync(localFile('certificates/server_chain.pem'))
20 ..usePrivateKeyBytes(readLocalFile('certificates/server_key.pem'), 19 ..usePrivateKeySync(localFile('certificates/server_key.pem'),
21 password: 'dartdart'); 20 password: 'dartdart');
22 21
23 SecurityContext clientContext = new SecurityContext() 22 SecurityContext clientContext = new SecurityContext()
24 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); 23 ..setTrustedCertificatesSync(localFile('certificates/trusted_certs.pem'));
25 24
26 Future<HttpServer> startServer() { 25 Future<HttpServer> startServer() {
27 return HttpServer.bindSecure( 26 return HttpServer.bindSecure(
28 "localhost", 27 "localhost",
29 0, 28 0,
30 serverContext, 29 serverContext,
31 backlog: 5).then((server) { 30 backlog: 5).then((server) {
32 server.listen((HttpRequest request) { 31 server.listen((HttpRequest request) {
33 request.listen( 32 request.listen(
34 (_) { }, 33 (_) { },
(...skipping 27 matching lines...) Expand all
62 server.close(); 61 server.close();
63 }, 62 },
64 onError: (e, trace) { 63 onError: (e, trace) {
65 String msg = "Unexpected error $e"; 64 String msg = "Unexpected error $e";
66 if (trace != null) msg += "\nStackTrace: $trace"; 65 if (trace != null) msg += "\nStackTrace: $trace";
67 Expect.fail(msg); 66 Expect.fail(msg);
68 }); 67 });
69 }); 68 });
70 }); 69 });
71 } 70 }
OLDNEW
« no previous file with comments | « tests/standalone/io/secure_socket_renegotiate_test.dart ('k') | tests/standalone/io/secure_unauthorized_client.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698