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

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

Issue 21716004: dart:io | Add SecureSocket.importPrivateCertificates, that reads a PKCS#12 file. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add delayed deletion of locked temp directory on Windows. 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. This client tests that addCertificate works if a certificate
9 // database has been specified.
10
11 import 'dart:io';
12
13 void main() {
14 int port = int.parse(new Options().arguments[0]);
15 String certificate = new Options().arguments[1];
16 String database = new Options().arguments[2];
17 SecureSocket.initialize(database: database,
18 password: 'dartdart',
19 readOnly: false);
20 SecureSocket.removeCertificate('localhost_cert');
21 SecureSocket.removeCertificate('myauthority_cert');
22 var mycert = new File(certificate).readAsBytesSync();
23 SecureSocket.addCertificate(mycert,
24 SecureSocket.TRUST_ISSUE_SERVER_CERTIFICATES);
25 if (null != SecureSocket.getCertificate('myauthority_cert')) {
26 throw "Expected getCertificate to return null";
27 }
28 SecureSocket.connect('localhost', port).then((SecureSocket socket) {
29 socket.writeln('hello world');
30 socket.listen((data) { });
31 return socket.close();
32 }).then((_) {
33 // The certificate is only in the in-memory cache, so cannot be removed.
34 try {
35 SecureSocket.removeCertificate('myauthority_cert');
36 } catch (e) {
37 if (e is! CertificateException) throw "error $e";
38 }
39 }).then((_) {
40 print('SUCCESS'); // Checked by parent process.
41 });
42 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698