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

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

Issue 2770573003: Add documentation to ALPN functionality in dart:io (Closed)
Patch Set: addressed comments Created 3 years, 9 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_server_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) 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 10 matching lines...) Expand all
21 * The certificate provided by the server is checked 21 * The certificate provided by the server is checked
22 * using the trusted certificates set in the SecurityContext object. 22 * using the trusted certificates set in the SecurityContext object.
23 * The default SecurityContext object contains a built-in set of trusted 23 * The default SecurityContext object contains a built-in set of trusted
24 * root certificates for well-known certificate authorities. 24 * root certificates for well-known certificate authorities.
25 * 25 *
26 * [onBadCertificate] is an optional handler for unverifiable certificates. 26 * [onBadCertificate] is an optional handler for unverifiable certificates.
27 * The handler receives the [X509Certificate], and can inspect it and 27 * The handler receives the [X509Certificate], and can inspect it and
28 * decide (or let the user decide) whether to accept 28 * decide (or let the user decide) whether to accept
29 * the connection or not. The handler should return true 29 * the connection or not. The handler should return true
30 * to continue the [SecureSocket] connection. 30 * to continue the [SecureSocket] connection.
31 *
32 * [supportedProtocols] is an optional list of protocols (in decreasing
33 * order of preference) to use during the ALPN protocol negogiation with the
34 * server. Example values are "http/1.1" or "h2". The selected protocol
35 * can be obtained via [SecureSocket.selectedProtocol].
31 */ 36 */
32 static Future<SecureSocket> connect(host, int port, 37 static Future<SecureSocket> connect(host, int port,
33 {SecurityContext context, 38 {SecurityContext context,
34 bool onBadCertificate(X509Certificate certificate), 39 bool onBadCertificate(X509Certificate certificate),
35 List<String> supportedProtocols}) { 40 List<String> supportedProtocols}) {
36 return RawSecureSocket 41 return RawSecureSocket
37 .connect(host, port, 42 .connect(host, port,
38 context: context, 43 context: context,
39 onBadCertificate: onBadCertificate, 44 onBadCertificate: onBadCertificate,
40 supportedProtocols: supportedProtocols) 45 supportedProtocols: supportedProtocols)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 /** 127 /**
123 * Get the peer certificate for a connected SecureSocket. If this 128 * Get the peer certificate for a connected SecureSocket. If this
124 * SecureSocket is the server end of a secure socket connection, 129 * SecureSocket is the server end of a secure socket connection,
125 * [peerCertificate] will return the client certificate, or null, if no 130 * [peerCertificate] will return the client certificate, or null, if no
126 * client certificate was received. If it is the client end, 131 * client certificate was received. If it is the client end,
127 * [peerCertificate] will return the server's certificate. 132 * [peerCertificate] will return the server's certificate.
128 */ 133 */
129 X509Certificate get peerCertificate; 134 X509Certificate get peerCertificate;
130 135
131 /** 136 /**
132 * Get the protocol which was selected during protocol negotiation. 137 * The protocol which was selected during ALPN protocol negotiation.
138 *
139 * Returns null if one of the peers does not have support for ALPN, did not
140 * specify a list of supported ALPN protocols or there was no common
141 * protocol between client and server.
133 */ 142 */
134 String get selectedProtocol; 143 String get selectedProtocol;
135 144
136 /** 145 /**
137 * Renegotiate an existing secure connection, renewing the session keys 146 * Renegotiate an existing secure connection, renewing the session keys
138 * and possibly changing the connection properties. 147 * and possibly changing the connection properties.
139 * 148 *
140 * This repeats the SSL or TLS handshake, with options that allow clearing 149 * This repeats the SSL or TLS handshake, with options that allow clearing
141 * the session cache and requesting a client certificate. 150 * the session cache and requesting a client certificate.
142 */ 151 */
(...skipping 24 matching lines...) Expand all
167 * certificates set in the SecurityContext object If a certificate and key are 176 * certificates set in the SecurityContext object If a certificate and key are
168 * set on the client, using [SecurityContext.useCertificateChain] and 177 * set on the client, using [SecurityContext.useCertificateChain] and
169 * [SecurityContext.usePrivateKey], and the server asks for a client 178 * [SecurityContext.usePrivateKey], and the server asks for a client
170 * certificate, then that client certificate is sent to the server. 179 * certificate, then that client certificate is sent to the server.
171 * 180 *
172 * [onBadCertificate] is an optional handler for unverifiable certificates. 181 * [onBadCertificate] is an optional handler for unverifiable certificates.
173 * The handler receives the [X509Certificate], and can inspect it and 182 * The handler receives the [X509Certificate], and can inspect it and
174 * decide (or let the user decide) whether to accept 183 * decide (or let the user decide) whether to accept
175 * the connection or not. The handler should return true 184 * the connection or not. The handler should return true
176 * to continue the [RawSecureSocket] connection. 185 * to continue the [RawSecureSocket] connection.
186 *
187 * [supportedProtocols] is an optional list of protocols (in decreasing
188 * order of preference) to use during the ALPN protocol negogiation with the
189 * server. Example values are "http/1.1" or "h2". The selected protocol
190 * can be obtained via [RawSecureSocket.selectedProtocol].
177 */ 191 */
178 static Future<RawSecureSocket> connect(host, int port, 192 static Future<RawSecureSocket> connect(host, int port,
179 {SecurityContext context, 193 {SecurityContext context,
180 bool onBadCertificate(X509Certificate certificate), 194 bool onBadCertificate(X509Certificate certificate),
181 List<String> supportedProtocols}) { 195 List<String> supportedProtocols}) {
182 _RawSecureSocket._verifyFields( 196 _RawSecureSocket._verifyFields(
183 host, port, false, false, false, onBadCertificate); 197 host, port, false, false, false, onBadCertificate);
184 return RawSocket.connect(host, port).then((socket) { 198 return RawSocket.connect(host, port).then((socket) {
185 return secure(socket, 199 return secure(socket,
186 context: context, 200 context: context,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 /** 307 /**
294 * Get the peer certificate for a connected RawSecureSocket. If this 308 * Get the peer certificate for a connected RawSecureSocket. If this
295 * RawSecureSocket is the server end of a secure socket connection, 309 * RawSecureSocket is the server end of a secure socket connection,
296 * [peerCertificate] will return the client certificate, or null, if no 310 * [peerCertificate] will return the client certificate, or null, if no
297 * client certificate was received. If it is the client end, 311 * client certificate was received. If it is the client end,
298 * [peerCertificate] will return the server's certificate. 312 * [peerCertificate] will return the server's certificate.
299 */ 313 */
300 X509Certificate get peerCertificate; 314 X509Certificate get peerCertificate;
301 315
302 /** 316 /**
303 * Get the protocol which was selected during protocol negotiation. 317 * The protocol which was selected during protocol negotiation.
318 *
319 * Returns null if one of the peers does not have support for ALPN, did not
320 * specify a list of supported ALPN protocols or there was no common
321 * protocol between client and server.
304 */ 322 */
305 String get selectedProtocol; 323 String get selectedProtocol;
306 } 324 }
307 325
308 /** 326 /**
309 * X509Certificate represents an SSL certificate, with accessors to 327 * X509Certificate represents an SSL certificate, with accessors to
310 * get the fields of the certificate. 328 * get the fields of the certificate.
311 */ 329 */
312 abstract class X509Certificate { 330 abstract class X509Certificate {
313 external factory X509Certificate._(); 331 external factory X509Certificate._();
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 1227
1210 /** 1228 /**
1211 * An exception that happens in the handshake phase of establishing 1229 * An exception that happens in the handshake phase of establishing
1212 * a secure network connection, when looking up or verifying a 1230 * a secure network connection, when looking up or verifying a
1213 * certificate. 1231 * certificate.
1214 */ 1232 */
1215 class CertificateException extends TlsException { 1233 class CertificateException extends TlsException {
1216 const CertificateException([String message = "", OSError osError = null]) 1234 const CertificateException([String message = "", OSError osError = null])
1217 : super._("CertificateException", message, osError); 1235 : super._("CertificateException", message, osError);
1218 } 1236 }
OLDNEW
« no previous file with comments | « sdk/lib/io/secure_server_socket.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698