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

Side by Side Diff: sdk/lib/io/secure_socket.dart

Issue 11583026: Add automatic initialization of SecureSocket library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Change documentation to match code. Created 8 years 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
« no previous file with comments | « runtime/bin/secure_socket.cc ('k') | tests/standalone/io/https_client_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of dart.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * SecureSocket provides a secure (SSL or TLS) client connection to a server. 8 * SecureSocket provides a secure (SSL or TLS) client connection to a server.
9 * The certificate provided by the server is checked 9 * The certificate provided by the server is checked
10 * using the certificate database provided in setCertificateDatabase. 10 * using the certificate database (optionally) provided in initialize().
11 */ 11 */
12 abstract class SecureSocket implements Socket { 12 abstract class SecureSocket implements Socket {
13 /** 13 /**
14 * Constructs a new secure client socket and connect it to the given 14 * Constructs a new secure client socket and connect it to the given
15 * host on the given port. The returned socket is not yet connected 15 * host on the given port. The returned socket is not yet connected
16 * but ready for registration of callbacks. If sendClientCertificate is 16 * but ready for registration of callbacks. If sendClientCertificate is
17 * set to true, the socket will send a client certificate if one is 17 * set to true, the socket will send a client certificate if one is
18 * requested by the server. If clientCertificate is the nickname of 18 * requested by the server. If clientCertificate is the nickname of
19 * a certificate in the certificate database, that certificate will be sent. 19 * a certificate in the certificate database, that certificate will be sent.
20 * If clientCertificate is null, which is the usual use case, an 20 * If clientCertificate is null, which is the usual use case, an
(...skipping 21 matching lines...) Expand all
42 42
43 /** 43 /**
44 * Get the peerCertificate for a connected secure socket. For a server 44 * Get the peerCertificate for a connected secure socket. For a server
45 * socket, this will return the client certificate, or null, if no 45 * socket, this will return the client certificate, or null, if no
46 * client certificate was received. For a client socket, this 46 * client certificate was received. For a client socket, this
47 * will return the server's certificate. 47 * will return the server's certificate.
48 */ 48 */
49 X509Certificate get peerCertificate; 49 X509Certificate get peerCertificate;
50 50
51 /** 51 /**
52 * Initializes the NSS library with the path to a certificate database 52 * Initializes the NSS library. If [initialize] is not called, the library
53 * is automatically initialized as if [initialize] were called with no
54 * arguments.
55 *
56 * The optional argument [database] is the path to a certificate database
53 * containing root certificates for verifying certificate paths on 57 * containing root certificates for verifying certificate paths on
54 * client connections, and server certificates to provide on server 58 * client connections, and server certificates to provide on server
55 * connections. The password argument should be used when creating 59 * connections. The argument [password] should be used when creating
56 * secure server sockets, to allow the private key of the server 60 * secure server sockets, to allow the private key of the server
57 * certificate to be fetched. If useBuiltinRoots is true (the default), 61 * certificate to be fetched. If [useBuiltinRoots] is true (the default),
58 * then a built-in set of root certificates for trusted certificate 62 * then a built-in set of root certificates for trusted certificate
59 * authorities is merged with the certificates in the database. 63 * authorities is merged with the certificates in the database.
60 * 64 *
61 * Examples: 65 * Examples:
62 * 1) Use only the builtin root certificates: 66 * 1) Use only the builtin root certificates:
63 * SecureSocket.initialize(); or 67 * SecureSocket.initialize(); or
64 * 68 *
65 * 2) Use a specified database and the builtin roots: 69 * 2) Use a specified database and the builtin roots:
66 * SecureSocket.initialize(database: 'path/to/my/database', 70 * SecureSocket.initialize(database: 'path/to/my/database',
67 * password: 'my_password'); 71 * password: 'my_password');
68 * 72 *
69 * 3) Use a specified database, without builtin roots: 73 * 3) Use a specified database, without builtin roots:
70 * SecureSocket.initialize(database: 'path/to/my/database', 74 * SecureSocket.initialize(database: 'path/to/my/database',
71 * password: 'my_password'. 75 * password: 'my_password'.
72 * useBuiltinRoots: false); 76 * useBuiltinRoots: false);
73 * 77 *
74 * The database should be an NSS certificate database directory 78 * The database should be an NSS certificate database directory
75 * containing a cert9.db file, not a cert8.db file. This version of 79 * containing a cert9.db file, not a cert8.db file. This version of
76 * the database can be created using the NSS certutil tool with "sql:" in 80 * the database can be created using the NSS certutil tool with "sql:" in
77 * front of the absolute path of the database directory, or setting the 81 * front of the absolute path of the database directory, or setting the
78 * environment variable NSS_DEFAULT_DB_TYPE to "sql". 82 * environment variable [[NSS_DEFAULT_DB_TYPE]] to "sql".
79 */ 83 */
80 external static void initialize({String database, 84 external static void initialize({String database,
81 String password, 85 String password,
82 bool useBuiltinRoots: true}); 86 bool useBuiltinRoots: true});
83 } 87 }
84 88
85 89
86 /** 90 /**
87 * X509Certificate represents an SSL certificate, with accessors to 91 * X509Certificate represents an SSL certificate, with accessors to
88 * get the fields of the certificate. 92 * get the fields of the certificate.
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 void destroy(); 674 void destroy();
671 void handshake(); 675 void handshake();
672 void init(); 676 void init();
673 X509Certificate get peerCertificate; 677 X509Certificate get peerCertificate;
674 int processBuffer(int bufferIndex); 678 int processBuffer(int bufferIndex);
675 void registerBadCertificateCallback(Function callback); 679 void registerBadCertificateCallback(Function callback);
676 void registerHandshakeCompleteCallback(Function handshakeCompleteHandler); 680 void registerHandshakeCompleteCallback(Function handshakeCompleteHandler);
677 681
678 List<_ExternalBuffer> get buffers; 682 List<_ExternalBuffer> get buffers;
679 } 683 }
OLDNEW
« no previous file with comments | « runtime/bin/secure_socket.cc ('k') | tests/standalone/io/https_client_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698