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

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

Issue 1845273004: Allows adding trusted certs on iOS. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 | « runtime/bin/secure_socket_macos.cc ('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.
11 * 11 *
12 * The [SecureSocket] and [SecureServer] classes take a SecurityContext 12 * The [SecureSocket] and [SecureServer] classes take a SecurityContext
13 * as an argument to their connect and bind methods. 13 * as an argument to their connect and bind methods.
14 * 14 *
15 * Certificates and keys can be added to a SecurityContext from either PEM 15 * Certificates and keys can be added to a SecurityContext from either PEM
16 * or PKCS12 containers. 16 * or PKCS12 containers.
17 * 17 *
18 * iOS note: methods to add, remove, and inspect certificates are not yet 18 * iOS note: Some methods to add, remove, and inspect certificates are not yet
19 * implemented. That is, only the platform's built-in trusted certificates can 19 * implemented. However, the platform's built-in trusted certificates can
20 * be used, by way of [SecurityContext.defaultContext]. 20 * be used, by way of [SecurityContext.defaultContext].
21 */ 21 */
22 abstract class SecurityContext { 22 abstract class SecurityContext {
23 external factory SecurityContext(); 23 external factory SecurityContext();
24 24
25 /** 25 /**
26 * Secure networking classes with an optional `context` parameter 26 * Secure networking classes with an optional `context` parameter
27 * use the [defaultContext] object if the parameter is omitted. 27 * use the [defaultContext] object if the parameter is omitted.
28 * This object can also be accessed, and modified, directly. 28 * This object can also be accessed, and modified, directly.
29 * Each isolate has a different [defaultContext] object. 29 * Each isolate has a different [defaultContext] object.
(...skipping 10 matching lines...) Expand all
40 * 40 *
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 *
51 * iOS note: Not yet implemented.
50 */ 52 */
51 void usePrivateKey(String file, {String password}); 53 void usePrivateKey(String file, {String password});
52 54
53 /** 55 /**
54 * Sets the private key for a server certificate or client certificate. 56 * Sets the private key for a server certificate or client certificate.
55 * 57 *
56 * Like [usePrivateKey], but takes the contents of the file as a list 58 * Like [usePrivateKey], but takes the contents of the file as a list
57 * of bytes. 59 * of bytes.
60 *
61 * iOS note: Not yet implemented.
58 */ 62 */
59 void usePrivateKeyBytes(List<int> keyBytes, {String password}); 63 void usePrivateKeyBytes(List<int> keyBytes, {String password});
60 64
61 /** 65 /**
62 * Sets the set of trusted X509 certificates used by [SecureSocket] 66 * Sets the set of trusted X509 certificates used by [SecureSocket]
63 * client connections, when connecting to a secure server. 67 * client connections, when connecting to a secure server.
64 * 68 *
65 * [file] is the path to a PEM or PKCS12 file containing X509 certificates, 69 * [file] is the path to a PEM or PKCS12 file containing X509 certificates,
66 * usually root certificates from certificate authorities. For PKCS12 files, 70 * usually root certificates from certificate authorities. For PKCS12 files,
67 * [password] is the password for the file. For PEM files, [password] is 71 * [password] is the password for the file. For PEM files, [password] is
68 * ignored. Assuming it is well-formatted, all other contents of [file] are 72 * ignored. Assuming it is well-formatted, all other contents of [file] are
69 * ignored. 73 * ignored.
70 * 74 *
71 * NB: This function calls [ReadFileAsBytesSync], and will block on file IO. 75 * NB: This function calls [ReadFileAsBytesSync], and will block on file IO.
72 * Prefer using [setTrustedCertificatesBytes]. 76 * Prefer using [setTrustedCertificatesBytes].
73 */ 77 */
74 void setTrustedCertificates(String file, {String password}); 78 void setTrustedCertificates(String file, {String password});
75 79
76 /** 80 /**
77 * Sets the set of trusted X509 certificates used by [SecureSocket] 81 * Sets the set of trusted X509 certificates used by [SecureSocket]
78 * client connections, when connecting to a secure server. 82 * client connections, when connecting to a secure server.
79 * 83 *
80 * Like [setTrustedCertificates] but takes the contents of the file. 84 * 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
81 */ 92 */
82 void setTrustedCertificatesBytes(List<int> certBytes, {String password}); 93 void setTrustedCertificatesBytes(List<int> certBytes, {String password});
83 94
84 /** 95 /**
85 * Sets the chain of X509 certificates served by [SecureServer] 96 * Sets the chain of X509 certificates served by [SecureServer]
86 * when making secure connections, including the server certificate. 97 * when making secure connections, including the server certificate.
87 * 98 *
88 * [file] is a PEM or PKCS12 file containing X509 certificates, starting with 99 * [file] is a PEM or PKCS12 file containing X509 certificates, starting with
89 * the root authority and intermediate authorities forming the signed 100 * the root authority and intermediate authorities forming the signed
90 * chain to the server certificate, and ending with the server certificate. 101 * chain to the server certificate, and ending with the server certificate.
91 * The private key for the server certificate is set by [usePrivateKey]. For 102 * The private key for the server certificate is set by [usePrivateKey]. For
92 * PKCS12 files, [password] is the password for the file. For PEM files, 103 * PKCS12 files, [password] is the password for the file. For PEM files,
93 * [password] is ignored. Assuming it is well-formatted, all 104 * [password] is ignored. Assuming it is well-formatted, all
94 * other contents of [file] are ignored. 105 * other contents of [file] are ignored.
95 * 106 *
96 * NB: This function calls [ReadFileAsBytesSync], and will block on file IO. 107 * NB: This function calls [ReadFileAsBytesSync], and will block on file IO.
97 * Prefer using [useCertificateChainBytes]. 108 * Prefer using [useCertificateChainBytes].
109 *
110 * iOS note: Not yet implemented.
98 */ 111 */
99 void useCertificateChain(String file, {String password}); 112 void useCertificateChain(String file, {String password});
100 113
101 /** 114 /**
102 * Sets the chain of X509 certificates served by [SecureServer] 115 * Sets the chain of X509 certificates served by [SecureServer]
103 * when making secure connections, including the server certificate. 116 * when making secure connections, including the server certificate.
104 * 117 *
105 * Like [useCertificateChain] but takes the contents of the file. 118 * Like [useCertificateChain] but takes the contents of the file.
119 *
120 * iOS note: Not yet implemented.
106 */ 121 */
107 void useCertificateChainBytes(List<int> chainBytes, {String password}); 122 void useCertificateChainBytes(List<int> chainBytes, {String password});
108 123
109 /** 124 /**
110 * Sets the list of authority names that a [SecureServer] will advertise 125 * Sets the list of authority names that a [SecureServer] will advertise
111 * as accepted when requesting a client certificate from a connecting 126 * as accepted when requesting a client certificate from a connecting
112 * client. 127 * client.
113 * 128 *
114 * [file] is a PEM or PKCS12 file containing the accepted signing 129 * [file] is a PEM or PKCS12 file containing the accepted signing
115 * authority certificates - the authority names are extracted from the 130 * authority certificates - the authority names are extracted from the
116 * certificates. For PKCS12 files, [password] is the password for the file. 131 * certificates. For PKCS12 files, [password] is the password for the file.
117 * 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
118 * other contents of [file] are ignored. 133 * other contents of [file] are ignored.
119 * 134 *
120 * NB: This function calls [ReadFileAsBytesSync], and will block on file IO. 135 * NB: This function calls [ReadFileAsBytesSync], and will block on file IO.
121 * Prefer using [setClientAuthoritiesBytes]. 136 * Prefer using [setClientAuthoritiesBytes].
137 *
138 * iOS note: Not yet implemented.
122 */ 139 */
123 void setClientAuthorities(String file, {String password}); 140 void setClientAuthorities(String file, {String password});
124 141
125 /** 142 /**
126 * Sets the list of authority names that a [SecureServer] will advertise 143 * Sets the list of authority names that a [SecureServer] will advertise
127 * as accepted, when requesting a client certificate from a connecting 144 * as accepted, when requesting a client certificate from a connecting
128 * client. 145 * client.
129 * 146 *
130 * 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.
131 */ 150 */
132 void setClientAuthoritiesBytes(List<int> authCertBytes, {String password}); 151 void setClientAuthoritiesBytes(List<int> authCertBytes, {String password});
133 152
134 /** 153 /**
135 * Whether the platform supports ALPN. 154 * Whether the platform supports ALPN.
136 */ 155 */
137 external static bool get alpnSupported; 156 external static bool get alpnSupported;
138 157
139 /** 158 /**
140 * Sets the list of application-level protocols supported by a client 159 * Sets the list of application-level protocols supported by a client
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 260 }
242 261
243 if (bytes.length >= (1 << 13)) { 262 if (bytes.length >= (1 << 13)) {
244 throw new ArgumentError( 263 throw new ArgumentError(
245 'The maximum message length supported is 2^13-1.'); 264 'The maximum message length supported is 2^13-1.');
246 } 265 }
247 266
248 return new Uint8List.fromList(bytes); 267 return new Uint8List.fromList(bytes);
249 } 268 }
250 } 269 }
OLDNEW
« no previous file with comments | « runtime/bin/secure_socket_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698