OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 * The object containing the certificates to trust when making | 8 * The object containing the certificates to trust when making |
9 * a secure client connection, and the certificate chain and | 9 * a secure client connection, and the certificate chain and |
10 * private key to serve from a secure server. | 10 * private key to serve from a secure server. |
(...skipping 23 matching lines...) Expand all Loading... | |
34 external static SecurityContext get defaultContext; | 34 external static SecurityContext get defaultContext; |
35 | 35 |
36 /** | 36 /** |
37 * Sets the private key for a server certificate or client certificate. | 37 * Sets the private key for a server certificate or client certificate. |
38 * | 38 * |
39 * A secure connection using this SecurityContext will use this key with | 39 * A secure connection using this SecurityContext will use this key with |
40 * the server or client certificate to sign and decrypt messages. | 40 * the server or client certificate to sign and decrypt messages. |
41 * [keyFile] is a PEM file containing an encrypted | 41 * [keyFile] is a PEM file containing an encrypted |
42 * private key, encrypted with [password]. An unencrypted file can be | 42 * private key, encrypted with [password]. An unencrypted file can be |
43 * used, but this is not usual. | 43 * used, but this is not usual. |
44 * | |
45 * The function returns a [Future] that completes when the key has been added | |
46 * to the context. | |
47 */ | 44 */ |
48 Future usePrivateKey(String keyFile, {String password}); | 45 void usePrivateKeySync(String keyFile, {String password}); |
49 | 46 |
50 /** | 47 /** |
51 * Sets the private key for a server certificate or client certificate. | 48 * Sets the private key for a server certificate or client certificate. |
52 * | 49 * |
53 * A secure connection using this SecurityContext will use this key with | 50 * A secure connection using this SecurityContext will use this key with |
54 * the server or client certificate to sign and decrypt messages. | 51 * the server or client certificate to sign and decrypt messages. |
55 * [keyBytes] is the contents of a PEM file containing an encrypted | 52 * [keyBytes] is the contents of a PEM file containing an encrypted |
56 * private key, encrypted with [password]. An unencrypted file can be | 53 * private key, encrypted with [password]. An unencrypted file can be |
57 * used, but this is not usual. | 54 * used, but this is not usual. |
58 */ | 55 */ |
59 void usePrivateKeyBytes(List<int> keyBytes, {String password}); | 56 void usePrivateKeyBytes(List<int> keyBytes, {String password}); |
60 | 57 |
61 /** | 58 /** |
62 * Sets the set of trusted X509 certificates used by [SecureSocket] | 59 * Sets the set of trusted X509 certificates used by [SecureSocket] |
63 * client connections, when connecting to a secure server. | 60 * client connections, when connecting to a secure server. |
64 * | 61 * |
65 * There are two ways to set a set of trusted certificates, with a single | 62 * [file] is the path to a PEM file containing X509 certificates, usually |
66 * PEM file, or with a directory containing individual PEM files for | 63 * root certificates from certificate authorities. |
67 * certificates. | 64 */ |
65 void setTrustedCertificatesSync(String file); | |
66 | |
67 /** | |
68 * Sets the set of trusted X509 certificates used by [SecureSocket] | |
69 * client connections, when connecting to a secure server. | |
68 * | 70 * |
69 * [file] is an optional PEM file containing X509 certificates, usually | 71 * [file] is the contents of a PEM file containing X509 certificates, usually |
70 * root certificates from certificate authorities. | 72 * root certificates from certificate authorities. |
71 * | |
72 * [directory] is an optional directory containing PEM files. The directory | |
73 * must also have filesystem links added, which link extra filenames based | |
74 * on the hash of a certificate's distinguished name (DN) to the file | |
75 * containing that certificate. OpenSSL contains a tool called c_rehash | |
76 * to create these links in a directory. | |
77 */ | 73 */ |
78 void setTrustedCertificates({String file, String directory}); | 74 void setTrustedCertificatesBytes(List<int> certBytes); |
79 | 75 |
80 /** | 76 /** |
81 * Sets the chain of X509 certificates served by [SecureServer] | 77 * Sets the chain of X509 certificates served by [SecureServer] |
82 * when making secure connections, including the server certificate. | 78 * when making secure connections, including the server certificate. |
83 * | 79 * |
84 * [file] is a PEM file containing X509 certificates, starting with | 80 * [file] is a PEM file containing X509 certificates, starting with |
85 * the root authority and intermediate authorities forming the signed | 81 * the root authority and intermediate authorities forming the signed |
86 * chain to the server certificate, and ending with the server certificate. | 82 * chain to the server certificate, and ending with the server certificate. |
87 * The private key for the server certificate is set by [usePrivateKey]. | 83 * The private key for the server certificate is set by [usePrivateKey]. |
88 * | |
89 * The function returns a [Future] that completes when the certificate chain | |
90 * has been set. | |
91 */ | 84 */ |
92 Future useCertificateChain(String file); | 85 void useCertificateChainSync(String file); |
93 | 86 |
94 /** | 87 /** |
95 * Sets the chain of X509 certificates served by [SecureServer] | 88 * Sets the chain of X509 certificates served by [SecureServer] |
96 * when making secure connections, including the server certificate. | 89 * when making secure connections, including the server certificate. |
97 * | 90 * |
98 * [chainBytes] is the contents of a PEM file containing X509 certificates, | 91 * [chainBytes] is the contents of a PEM file containing X509 certificates, |
99 * starting with the root authority and intermediate authorities forming the | 92 * starting with the root authority and intermediate authorities forming the |
100 * signed chain to the server certificate, and ending with the server | 93 * signed chain to the server certificate, and ending with the server |
101 * certificate. The private key for the server certificate is set by | 94 * certificate. The private key for the server certificate is set by |
102 * [usePrivateKey]. | 95 * [usePrivateKey]. |
103 */ | 96 */ |
104 void useCertificateChainBytes(List<int> chainBytes); | 97 void useCertificateChainBytes(List<int> chainBytes); |
105 | 98 |
106 /** | 99 /** |
107 * Sets the list of authority names that a [SecureServer] will advertise | 100 * Sets the list of authority names that a [SecureServer] will advertise |
108 * as accepted, when requesting a client certificate from a connecting | 101 * as accepted, when requesting a client certificate from a connecting |
109 * client. [file] is a PEM file containing the accepted signing authority | 102 * client. [file] is a PEM file containing the accepted signing authority |
110 * certificates - the authority names are extracted from the certificates. | 103 * certificates - the authority names are extracted from the certificates. |
111 */ | 104 */ |
112 void setClientAuthorities(String file); | 105 void setClientAuthoritiesSync(String file); |
kevmoo
2016/02/05 22:26:06
Keep this API around for 1.15 marked as deprecated
zra
2016/02/05 23:10:39
Done.
| |
106 | |
107 /** | |
108 * Sets the list of authority names that a [SecureServer] will advertise | |
109 * as accepted, when requesting a client certificate from a connecting | |
110 * client. [authCertBytes] is the contents of a PEM file containing the | |
111 * accepted signing authority certificates - the authority names are extracted | |
112 * from the certificates. | |
113 */ | |
114 void setClientAuthoritiesBytes(List<int> authCertBytes); | |
113 | 115 |
114 /** | 116 /** |
115 * Sets the list of application-level protocols supported by a client | 117 * Sets the list of application-level protocols supported by a client |
116 * connection or server connection. The ALPN (application level protocol | 118 * connection or server connection. The ALPN (application level protocol |
117 * negotiation) extension to TLS allows a client to send a list of | 119 * negotiation) extension to TLS allows a client to send a list of |
118 * protocols in the TLS client hello message, and the server to pick | 120 * protocols in the TLS client hello message, and the server to pick |
119 * one and send the selected one back in its server hello message. | 121 * one and send the selected one back in its server hello message. |
120 * | 122 * |
121 * Separate lists of protocols can be sent for client connections and | 123 * Separate lists of protocols can be sent for client connections and |
122 * for server connections, using the same SecurityContext. The [isServer] | 124 * for server connections, using the same SecurityContext. The [isServer] |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 } | 218 } |
217 | 219 |
218 if (bytes.length >= (1 << 13)) { | 220 if (bytes.length >= (1 << 13)) { |
219 throw new ArgumentError( | 221 throw new ArgumentError( |
220 'The maximum message length supported is 2^13-1.'); | 222 'The maximum message length supported is 2^13-1.'); |
221 } | 223 } |
222 | 224 |
223 return new Uint8List.fromList(bytes); | 225 return new Uint8List.fromList(bytes); |
224 } | 226 } |
225 } | 227 } |
OLD | NEW |