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

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

Issue 14493015: Add HTTP proxy tunnel support (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 * handshake to make the communication secure. When the returned 53 * handshake to make the communication secure. When the returned
54 * future completes the [SecureSocket] has completed the TLS 54 * future completes the [SecureSocket] has completed the TLS
55 * handshake. Using this function requires that the other end of the 55 * handshake. Using this function requires that the other end of the
56 * connection is prepared for TLS handshake. 56 * connection is prepared for TLS handshake.
57 * 57 *
58 * If the [socket] already has a subscription, this subscription 58 * If the [socket] already has a subscription, this subscription
59 * will no longer receive and events. In most cases calling 59 * will no longer receive and events. In most cases calling
60 * [:pause:] on this subscription before starting TLS handshake is 60 * [:pause:] on this subscription before starting TLS handshake is
61 * the right thing to do. 61 * the right thing to do.
62 * 62 *
63 * If the [host] argument is passed it will be used as the host name
64 * for the TLS handshake. If [host] is not passed the host name from
65 * the [socket] will be used. The [host] can be either a [String] or
66 * an [InternetAddress].
67 *
63 * See [connect] for more information on the arguments. 68 * See [connect] for more information on the arguments.
64 * 69 *
65 */ 70 */
66 static Future<SecureSocket> secure( 71 static Future<SecureSocket> secure(
67 Socket socket, 72 Socket socket,
68 {bool sendClientCertificate: false, 73 {host,
74 bool sendClientCertificate: false,
69 String certificateName, 75 String certificateName,
70 bool onBadCertificate(X509Certificate certificate)}) { 76 bool onBadCertificate(X509Certificate certificate)}) {
71 var completer = new Completer(); 77 var completer = new Completer();
72 (socket as dynamic)._detachRaw() 78 (socket as dynamic)._detachRaw()
73 .then((detachedRaw) { 79 .then((detachedRaw) {
74 return RawSecureSocket.secure( 80 return RawSecureSocket.secure(
75 detachedRaw[0], 81 detachedRaw[0],
76 subscription: detachedRaw[1], 82 subscription: detachedRaw[1],
83 host: host,
77 sendClientCertificate: sendClientCertificate, 84 sendClientCertificate: sendClientCertificate,
78 onBadCertificate: onBadCertificate); 85 onBadCertificate: onBadCertificate);
79 }) 86 })
80 .then((raw) { 87 .then((raw) {
81 completer.complete(new SecureSocket._(raw)); 88 completer.complete(new SecureSocket._(raw));
82 }); 89 });
83 return completer.future; 90 return completer.future;
84 } 91 }
85 92
86 /** 93 /**
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 * subscription in the [subscription] parameter. The secure socket 240 * subscription in the [subscription] parameter. The secure socket
234 * will take over the subscription and process any subsequent 241 * will take over the subscription and process any subsequent
235 * events. 242 * events.
236 * 243 *
237 * See [connect] for more information on the arguments. 244 * See [connect] for more information on the arguments.
238 * 245 *
239 */ 246 */
240 static Future<RawSecureSocket> secure( 247 static Future<RawSecureSocket> secure(
241 RawSocket socket, 248 RawSocket socket,
242 {StreamSubscription subscription, 249 {StreamSubscription subscription,
250 host,
243 bool sendClientCertificate: false, 251 bool sendClientCertificate: false,
244 String certificateName, 252 String certificateName,
245 bool onBadCertificate(X509Certificate certificate)}) { 253 bool onBadCertificate(X509Certificate certificate)}) {
246 return _RawSecureSocket.connect( 254 return _RawSecureSocket.connect(
247 socket.address, 255 host != null ? host : socket.address,
248 socket.port, 256 socket.port,
249 certificateName, 257 certificateName,
250 is_server: false, 258 is_server: false,
251 socket: socket, 259 socket: socket,
252 subscription: subscription, 260 subscription: subscription,
253 sendClientCertificate: sendClientCertificate, 261 sendClientCertificate: sendClientCertificate,
254 onBadCertificate: onBadCertificate); 262 onBadCertificate: onBadCertificate);
255 } 263 }
256 264
257 /** 265 /**
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 // create a new one. 450 // create a new one.
443 _socketSubscription = _socket.listen(_eventDispatcher, 451 _socketSubscription = _socket.listen(_eventDispatcher,
444 onError: _errorHandler, 452 onError: _errorHandler,
445 onDone: _doneHandler); 453 onDone: _doneHandler);
446 } else { 454 } else {
447 _socketSubscription.onData(_eventDispatcher); 455 _socketSubscription.onData(_eventDispatcher);
448 _socketSubscription.onError(_errorHandler); 456 _socketSubscription.onError(_errorHandler);
449 _socketSubscription.onDone(_doneHandler); 457 _socketSubscription.onDone(_doneHandler);
450 } 458 }
451 _connectPending = true; 459 _connectPending = true;
452 _secureFilter.connect(rawSocket.address.host, 460 _secureFilter.connect(address.host,
453 port, 461 port,
454 is_server, 462 is_server,
455 certificateName, 463 certificateName,
456 requestClientCertificate || 464 requestClientCertificate ||
457 requireClientCertificate, 465 requireClientCertificate,
458 requireClientCertificate, 466 requireClientCertificate,
459 sendClientCertificate); 467 sendClientCertificate);
460 _status = HANDSHAKE; 468 _status = HANDSHAKE;
461 _secureHandshake(); 469 _secureHandshake();
462 }) 470 })
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 void destroy(); 961 void destroy();
954 void handshake(); 962 void handshake();
955 void init(); 963 void init();
956 X509Certificate get peerCertificate; 964 X509Certificate get peerCertificate;
957 int processBuffer(int bufferIndex); 965 int processBuffer(int bufferIndex);
958 void registerBadCertificateCallback(Function callback); 966 void registerBadCertificateCallback(Function callback);
959 void registerHandshakeCompleteCallback(Function handshakeCompleteHandler); 967 void registerHandshakeCompleteCallback(Function handshakeCompleteHandler);
960 968
961 List<_ExternalBuffer> get buffers; 969 List<_ExternalBuffer> get buffers;
962 } 970 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698