OLD | NEW |
---|---|
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 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 /** | 7 /** |
8 * A high-level class for communicating securely over a TCP socket, using | 8 * A high-level class for communicating securely over a TCP socket, using |
9 * TLS and SSL. The [SecureSocket] exposes both a [Stream] and an | 9 * TLS and SSL. The [SecureSocket] exposes both a [Stream] and an |
10 * [IOSink] interface, making it ideal for using together with | 10 * [IOSink] interface, making it ideal for using together with |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 host: host, | 89 host: host, |
90 sendClientCertificate: sendClientCertificate, | 90 sendClientCertificate: sendClientCertificate, |
91 onBadCertificate: onBadCertificate); | 91 onBadCertificate: onBadCertificate); |
92 }) | 92 }) |
93 .then((raw) { | 93 .then((raw) { |
94 completer.complete(new SecureSocket._(raw)); | 94 completer.complete(new SecureSocket._(raw)); |
95 }); | 95 }); |
96 return completer.future; | 96 return completer.future; |
97 } | 97 } |
98 | 98 |
99 | |
100 /** | 99 /** |
101 * Takes an already connected [socket] and starts server side TLS | 100 * Takes an already connected [socket] and starts server side TLS |
102 * handshake to make the communication secure. When the returned | 101 * handshake to make the communication secure. When the returned |
103 * future completes the [SecureSocket] has completed the TLS | 102 * future completes the [SecureSocket] has completed the TLS |
104 * handshake. Using this function requires that the other end of the | 103 * handshake. Using this function requires that the other end of the |
105 * connection is going to start the TLS handshake. | 104 * connection is going to start the TLS handshake. |
106 * | 105 * |
107 * If the [socket] already has a subscription, this subscription | 106 * If the [socket] already has a subscription, this subscription |
108 * will no longer receive and events. In most cases calling | 107 * will no longer receive and events. In most cases calling |
109 * [:pause:] on this subscription before starting TLS handshake is | 108 * [:pause:] on this subscription before starting TLS handshake is |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 * useBuiltinRoots: false); | 197 * useBuiltinRoots: false); |
199 * | 198 * |
200 * The database should be an NSS certificate database directory | 199 * The database should be an NSS certificate database directory |
201 * containing a cert9.db file, not a cert8.db file. This version of | 200 * containing a cert9.db file, not a cert8.db file. This version of |
202 * the database can be created using the NSS certutil tool with "sql:" in | 201 * the database can be created using the NSS certutil tool with "sql:" in |
203 * front of the absolute path of the database directory, or setting the | 202 * front of the absolute path of the database directory, or setting the |
204 * environment variable [[NSS_DEFAULT_DB_TYPE]] to "sql". | 203 * environment variable [[NSS_DEFAULT_DB_TYPE]] to "sql". |
205 */ | 204 */ |
206 external static void initialize({String database, | 205 external static void initialize({String database, |
207 String password, | 206 String password, |
208 bool useBuiltinRoots: true}); | 207 bool useBuiltinRoots: true, |
209 | 208 bool readOnly: true}); |
210 | 209 |
211 /** | 210 /** |
212 * Trust strings for use in [addCertificate]. | 211 * Trust strings for use in [addCertificate] and [changeTrust]. |
213 */ | 212 */ |
214 static const String TRUST_ISSUE_SERVER_CERTIFICATES = 'C,,'; | 213 static const String TRUST_ISSUE_SERVER_CERTIFICATES = 'C,,'; |
215 static const String TRUST_ISSUE_CLIENT_CERTIFICATES = 'T,,'; | 214 static const String TRUST_ISSUE_CLIENT_CERTIFICATES = 'T,,'; |
216 static const String TRUST_ISSUE_CLIENT_SERVER_CERTIFICATES = 'TC,,'; | 215 static const String TRUST_ISSUE_CLIENT_SERVER_CERTIFICATES = 'TC,,'; |
217 static const String TRUST_CERTIFICATE = 'P,,'; | 216 static const String TRUST_CERTIFICATE = 'P,,'; |
218 | 217 |
219 | |
220 /** | 218 /** |
221 * Adds a X509 certificate (for SSL and TLS secure networking) to the | 219 * Adds a X509 certificate (for SSL and TLS secure networking) to the |
222 * in-memory certificate database. Returns an X509Certificate object | 220 * in-memory certificate database. Returns an X509Certificate object |
223 * with information about the added certificate. | 221 * with information about the added certificate. |
224 * | 222 * |
225 * [certificate] must be a list of bytes encoding a certificate in | 223 * [certificate] must be a list of bytes encoding a certificate in |
226 * PEM format: a base64 encoded DER certificate, enclosed between | 224 * PEM format: a base64 encoded DER certificate, enclosed between |
227 * "-----BEGIN CERTIFICATE-----" and "-----END CERTIFICATE-----". | 225 * "-----BEGIN CERTIFICATE-----" and "-----END CERTIFICATE-----". |
228 * | 226 * |
229 * [trust] is a string specifying the allowed uses of this certificate. | 227 * [trust] is a string specifying the allowed uses of this certificate. |
230 * For example, 'TC,,' specifies that the certificate is for a certificate | 228 * For example, 'TC,,' specifies that the certificate is for a certificate |
231 * authority that is trusted to issue server and client certificates, so | 229 * authority that is trusted to issue server and client certificates, so |
232 * that a server or client certificate signed by this authority will be | 230 * that a server or client certificate signed by this authority will be |
233 * accepted. | 231 * accepted. |
234 * | 232 * |
235 * See the documentation of NSS certutil at | 233 * See the documentation of NSS certutil at |
236 * http://developer.mozilla.org/en-US/docs/NSS_reference/NSS_tools_:_certutil | 234 * http://developer.mozilla.org/en-US/docs/NSS_reference/NSS_tools_:_certutil |
237 * or | 235 * or |
238 * http://blogs.oracle.com/meena/entry/notes_about_trust_flags | 236 * http://blogs.oracle.com/meena/entry/notes_about_trust_flags |
239 * for more information about trust attributes. | 237 * for more information about trust attributes. |
240 */ | 238 */ |
241 external static X509Certificate addCertificate(List<int> certificate, | 239 external static X509Certificate addCertificate(List<int> certificate, |
242 String trust); | 240 String trust); |
241 | |
242 /** | |
243 * Adds a X509 certificates (for SSL and TLS secure networking) with | |
244 * their private keys to the in-memory certificate database. | |
Søren Gjesse
2013/08/07 07:32:28
As I understood it is not only imported into the i
Bill Hesse
2013/08/08 17:39:21
Removed in-memory database. Will check what happe
| |
245 * | |
246 * [certificates] must be a list containing the bytes of a PKCS#12 encoded | |
247 * list of certificates and private keys. These are commonly called | |
248 * .pk files. | |
Søren Gjesse
2013/08/07 07:32:28
Change the .pk extension.
Put `` around extension
Bill Hesse
2013/08/08 17:39:21
Done.
| |
249 * | |
Søren Gjesse
2013/08/07 07:32:28
If limiting the ciphers please list the range whic
Bill Hesse
2013/08/08 17:39:21
Done.
| |
250 * All certificates are imported with no default trust, and the appropriate | |
251 * uses of each certificate must be added with SecureSocket.changeTrust. | |
Søren Gjesse
2013/08/07 07:32:28
Add `` around SecureSocket.changeTrust.
Bill Hesse
2013/08/08 17:39:21
Done.
| |
252 * | |
253 * See the documentation of NSS certutil at | |
254 * http://developer.mozilla.org/en-US/docs/NSS_reference/NSS_tools_:_certutil | |
255 * or | |
256 * http://blogs.oracle.com/meena/entry/notes_about_trust_flags | |
257 * for more information about trust attributes. | |
258 */ | |
259 external static importPrivateCertificates(List<int> certificates, | |
260 String password); | |
261 | |
262 /** | |
263 * Changes the trust settings for the certificate with nickname [nickname]. | |
264 * This certificate can be in a permanent certificate database, or | |
265 * in the temporary in-memory database of certificates. | |
266 * | |
267 * [trust] is a string specifying the allowed uses of this certificate. | |
268 * For example, 'TC,,' specifies that the certificate is for a certificate | |
269 * authority that is trusted to issue server and client certificates, so | |
270 * that a server or client certificate signed by this authority will be | |
271 * accepted. | |
272 * | |
273 * See the documentation of NSS certutil at | |
274 * http://developer.mozilla.org/en-US/docs/NSS_reference/NSS_tools_:_certutil | |
275 * or | |
276 * http://blogs.oracle.com/meena/entry/notes_about_trust_flags | |
277 * for more information about trust attributes. | |
278 */ | |
279 external static X509Certificate changeTrust(String nickname, | |
280 String trust); | |
281 | |
282 /** | |
283 * Removes the certificate with nickname [nickname] permanently from | |
284 * the certificate database. | |
285 */ | |
286 external static removeCertificate(String nickname); | |
243 } | 287 } |
244 | 288 |
245 | 289 |
246 /** | 290 /** |
247 * RawSecureSocket provides a secure (SSL or TLS) network connection. | 291 * RawSecureSocket provides a secure (SSL or TLS) network connection. |
248 * Client connections to a server are provided by calling | 292 * Client connections to a server are provided by calling |
249 * RawSecureSocket.connect. A secure server, created with | 293 * RawSecureSocket.connect. A secure server, created with |
250 * RawSecureServerSocket, also returns RawSecureSocket objects representing | 294 * RawSecureServerSocket, also returns RawSecureSocket objects representing |
251 * the server end of a secure connection. | 295 * the server end of a secure connection. |
252 * The certificate provided by the server is checked | 296 * The certificate provided by the server is checked |
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1304 /** | 1348 /** |
1305 * An exception that happens in the handshake phase of establishing | 1349 * An exception that happens in the handshake phase of establishing |
1306 * a secure network connection, when looking up or verifying a | 1350 * a secure network connection, when looking up or verifying a |
1307 * certificate. | 1351 * certificate. |
1308 */ | 1352 */ |
1309 class CertificateException extends TlsException { | 1353 class CertificateException extends TlsException { |
1310 const CertificateException([String message = "", | 1354 const CertificateException([String message = "", |
1311 OSError osError = null]) | 1355 OSError osError = null]) |
1312 : super._("CertificateException", message, osError); | 1356 : super._("CertificateException", message, osError); |
1313 } | 1357 } |
OLD | NEW |