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

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

Issue 1852783003: Implements remaining SecurityContext calls for iOS (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 8 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
« no previous file with comments | « sdk/lib/io/secure_socket.dart ('k') | no next file » | 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) 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 30 matching lines...) Expand all
41 * A secure connection using this SecurityContext will use this key with 41 * A secure connection using this SecurityContext will use this key with
42 * the server or client certificate to sign and decrypt messages. 42 * the server or client certificate to sign and decrypt messages.
43 * [file] is the path to a PEM or PKCS12 file containing an encrypted 43 * [file] is the path to a PEM or PKCS12 file containing an encrypted
44 * private key, encrypted with [password]. Assuming it is well-formatted, all 44 * private key, encrypted with [password]. Assuming it is well-formatted, all
45 * other contents of [file] are ignored. An unencrypted file can be used, 45 * other contents of [file] are ignored. An unencrypted file can be used,
46 * but this is not usual. 46 * but this is not usual.
47 * 47 *
48 * NB: This function calls [ReadFileAsBytesSync], and will block on file IO. 48 * NB: This function calls [ReadFileAsBytesSync], and will block on file IO.
49 * Prefer using [usePrivateKeyBytes]. 49 * Prefer using [usePrivateKeyBytes].
50 * 50 *
51 * iOS note: Not yet implemented. 51 * iOS note: Only PKCS12 data is supported. It should contain both the private
52 * key and the certificate chain. On iOS one call to [usePrivateKey] with this
53 * data is used instead of two calls to [useCertificateChain] and
54 * [usePrivateKey].
52 */ 55 */
53 void usePrivateKey(String file, {String password}); 56 void usePrivateKey(String file, {String password});
54 57
55 /** 58 /**
56 * Sets the private key for a server certificate or client certificate. 59 * Sets the private key for a server certificate or client certificate.
57 * 60 *
58 * Like [usePrivateKey], but takes the contents of the file as a list 61 * Like [usePrivateKey], but takes the contents of the file as a list
59 * of bytes. 62 * of bytes.
60 *
61 * iOS note: Not yet implemented.
62 */ 63 */
63 void usePrivateKeyBytes(List<int> keyBytes, {String password}); 64 void usePrivateKeyBytes(List<int> keyBytes, {String password});
64 65
65 /** 66 /**
66 * Sets the set of trusted X509 certificates used by [SecureSocket] 67 * Sets the set of trusted X509 certificates used by [SecureSocket]
67 * client connections, when connecting to a secure server. 68 * client connections, when connecting to a secure server.
68 * 69 *
69 * [file] is the path to a PEM or PKCS12 file containing X509 certificates, 70 * [file] is the path to a PEM or PKCS12 file containing X509 certificates,
70 * usually root certificates from certificate authorities. For PKCS12 files, 71 * usually root certificates from certificate authorities. For PKCS12 files,
71 * [password] is the password for the file. For PEM files, [password] is 72 * [password] is the password for the file. For PEM files, [password] is
72 * ignored. Assuming it is well-formatted, all other contents of [file] are 73 * ignored. Assuming it is well-formatted, all other contents of [file] are
73 * ignored. 74 * ignored.
74 * 75 *
75 * NB: This function calls [ReadFileAsBytesSync], and will block on file IO. 76 * NB: This function calls [ReadFileAsBytesSync], and will block on file IO.
76 * Prefer using [setTrustedCertificatesBytes]. 77 * Prefer using [setTrustedCertificatesBytes].
78 *
79 * iOS note: On iOS, this call takes only the bytes for a single DER
80 * encoded X509 certificate. It may be called multiple times to add
81 * multiple trusted certificates to the context. A DER encoded certificate
82 * can be obtained from a PEM encoded certificate by using the openssl tool:
83 *
84 * $ openssl x509 -outform der -in cert.pem -out cert.der
77 */ 85 */
78 void setTrustedCertificates(String file, {String password}); 86 void setTrustedCertificates(String file, {String password});
79 87
80 /** 88 /**
81 * Sets the set of trusted X509 certificates used by [SecureSocket] 89 * Sets the set of trusted X509 certificates used by [SecureSocket]
82 * client connections, when connecting to a secure server. 90 * client connections, when connecting to a secure server.
83 * 91 *
84 * Like [setTrustedCertificates] but takes the contents of the file. 92 * Like [setTrustedCertificates] but takes the contents of the file.
85 *
86 * iOS note: On iOS, this call takes only the bytes for a single DER
87 * encoded X509 certificate. It may be called multiple times to add
88 * multiple trusted certificates to the context. A DER encoded certificate
89 * can be obtained from a PEM encoded certificate by using the openssl tool:
90 *
91 * $ openssl x509 -outform der -in cert.pem -out cert.der
92 */ 93 */
93 void setTrustedCertificatesBytes(List<int> certBytes, {String password}); 94 void setTrustedCertificatesBytes(List<int> certBytes, {String password});
94 95
95 /** 96 /**
96 * Sets the chain of X509 certificates served by [SecureServer] 97 * Sets the chain of X509 certificates served by [SecureServer]
97 * when making secure connections, including the server certificate. 98 * when making secure connections, including the server certificate.
98 * 99 *
99 * [file] is a PEM or PKCS12 file containing X509 certificates, starting with 100 * [file] is a PEM or PKCS12 file containing X509 certificates, starting with
100 * the root authority and intermediate authorities forming the signed 101 * the root authority and intermediate authorities forming the signed
101 * chain to the server certificate, and ending with the server certificate. 102 * chain to the server certificate, and ending with the server certificate.
102 * The private key for the server certificate is set by [usePrivateKey]. For 103 * The private key for the server certificate is set by [usePrivateKey]. For
103 * PKCS12 files, [password] is the password for the file. For PEM files, 104 * PKCS12 files, [password] is the password for the file. For PEM files,
104 * [password] is ignored. Assuming it is well-formatted, all 105 * [password] is ignored. Assuming it is well-formatted, all
105 * other contents of [file] are ignored. 106 * other contents of [file] are ignored.
106 * 107 *
107 * NB: This function calls [ReadFileAsBytesSync], and will block on file IO. 108 * NB: This function calls [ReadFileAsBytesSync], and will block on file IO.
108 * Prefer using [useCertificateChainBytes]. 109 * Prefer using [useCertificateChainBytes].
109 * 110 *
110 * iOS note: Not yet implemented. 111 * iOS note: As noted above, [usePrivateKey] does the job of both
112 * that call and this one. On iOS, this call is a no-op.
111 */ 113 */
112 void useCertificateChain(String file, {String password}); 114 void useCertificateChain(String file, {String password});
113 115
114 /** 116 /**
115 * Sets the chain of X509 certificates served by [SecureServer] 117 * Sets the chain of X509 certificates served by [SecureServer]
116 * when making secure connections, including the server certificate. 118 * when making secure connections, including the server certificate.
117 * 119 *
118 * Like [useCertificateChain] but takes the contents of the file. 120 * Like [useCertificateChain] but takes the contents of the file.
119 *
120 * iOS note: Not yet implemented.
121 */ 121 */
122 void useCertificateChainBytes(List<int> chainBytes, {String password}); 122 void useCertificateChainBytes(List<int> chainBytes, {String password});
123 123
124 /** 124 /**
125 * Sets the list of authority names that a [SecureServer] will advertise 125 * Sets the list of authority names that a [SecureServer] will advertise
126 * as accepted when requesting a client certificate from a connecting 126 * as accepted when requesting a client certificate from a connecting
127 * client. 127 * client.
128 * 128 *
129 * [file] is a PEM or PKCS12 file containing the accepted signing 129 * [file] is a PEM or PKCS12 file containing the accepted signing
130 * authority certificates - the authority names are extracted from the 130 * authority certificates - the authority names are extracted from the
131 * certificates. For PKCS12 files, [password] is the password for the file. 131 * certificates. For PKCS12 files, [password] is the password for the file.
132 * For PEM files, [password] is ignored. Assuming it is well-formatted, all 132 * For PEM files, [password] is ignored. Assuming it is well-formatted, all
133 * other contents of [file] are ignored. 133 * other contents of [file] are ignored.
134 * 134 *
135 * NB: This function calls [ReadFileAsBytesSync], and will block on file IO. 135 * NB: This function calls [ReadFileAsBytesSync], and will block on file IO.
136 * Prefer using [setClientAuthoritiesBytes]. 136 * Prefer using [setClientAuthoritiesBytes].
137 * 137 *
138 * iOS note: Not yet implemented. 138 * iOS note: This call is not supported.
139 */ 139 */
140 void setClientAuthorities(String file, {String password}); 140 void setClientAuthorities(String file, {String password});
141 141
142 /** 142 /**
143 * Sets the list of authority names that a [SecureServer] will advertise 143 * Sets the list of authority names that a [SecureServer] will advertise
144 * as accepted, when requesting a client certificate from a connecting 144 * as accepted, when requesting a client certificate from a connecting
145 * client. 145 * client.
146 * 146 *
147 * Like [setClientAuthority] but takes the contents of the file. 147 * Like [setClientAuthority] but takes the contents of the file.
148 *
149 * iOS note: Not yet implemented.
150 */ 148 */
151 void setClientAuthoritiesBytes(List<int> authCertBytes, {String password}); 149 void setClientAuthoritiesBytes(List<int> authCertBytes, {String password});
152 150
153 /** 151 /**
154 * Whether the platform supports ALPN. 152 * Whether the platform supports ALPN.
155 */ 153 */
156 external static bool get alpnSupported; 154 external static bool get alpnSupported;
157 155
158 /** 156 /**
159 * Sets the list of application-level protocols supported by a client 157 * Sets the list of application-level protocols supported by a client
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 258 }
261 259
262 if (bytes.length >= (1 << 13)) { 260 if (bytes.length >= (1 << 13)) {
263 throw new ArgumentError( 261 throw new ArgumentError(
264 'The maximum message length supported is 2^13-1.'); 262 'The maximum message length supported is 2^13-1.');
265 } 263 }
266 264
267 return new Uint8List.fromList(bytes); 265 return new Uint8List.fromList(bytes);
268 } 266 }
269 } 267 }
OLDNEW
« no previous file with comments | « sdk/lib/io/secure_socket.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698