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

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

Issue 18097007: Add SecureSocket.addCertificate. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove nickname argument. Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 //
5 // Client that tests that a certificate authority certificate loaded
6 // at runtime can be used to verify a certificate chain. The server it
7 // connects to uses localhost_cert, signed by myauthority_cert, to connect
8 // securely.
9
10 import 'dart:io';
11
12 void main() {
13 int port = int.parse(new Options().arguments[0]);
14 String certificate = new Options().arguments[1];
15 SecureSocket.initialize();
16 var mycert = new File(certificate).readAsBytesSync();
17 bool threw = false;
18 try {
19 SecureSocket.addCertificate("I am not a cert".codeUnits, 'C,,');
20 } on CertificateException catch (e) {
21 threw = true;
22 }
23 if (!threw) throw new AssertException("Expected bad certificate to throw");
24
25 threw = false;
26 try {
27 SecureSocket.addCertificate(mycert, "Trust me, I'm a string");
28 } on CertificateException catch (e) {
29 threw = true;
30 }
31 if (!threw) throw new AssertException("Expected bad trust string to throw");
32
33
34 SecureSocket.addCertificate(mycert,
35 'C,,');
36 SecureSocket.connect('localhost', port).then((SecureSocket socket) {
37 socket.writeln("hello world");
38 socket.listen((data) { });
39 socket.close();
40 });
41 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698