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

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

Issue 18984008: dart:io | Support connection renegotiation (rehandshake) on SecureSocket. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix indentation and remove whitespace in test file. Created 7 years, 5 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 /** 143 /**
144 * Get the peer certificate for a connected SecureSocket. If this 144 * Get the peer certificate for a connected SecureSocket. If this
145 * SecureSocket is the server end of a secure socket connection, 145 * SecureSocket is the server end of a secure socket connection,
146 * [peerCertificate] will return the client certificate, or null, if no 146 * [peerCertificate] will return the client certificate, or null, if no
147 * client certificate was received. If it is the client end, 147 * client certificate was received. If it is the client end,
148 * [peerCertificate] will return the server's certificate. 148 * [peerCertificate] will return the server's certificate.
149 */ 149 */
150 X509Certificate get peerCertificate; 150 X509Certificate get peerCertificate;
151 151
152 /** 152 /**
153 * Renegotiate an existing secure connection, renewing the session keys
154 * and possibly changing the connection properties.
155 *
156 * This repeats the SSL or TLS handshake, with options that allow clearing
157 * the session cache and requesting a client certificate.
158 */
159 void renegotiate({bool useSessionCache: true,
160 bool requestClientCertificate: false,
161 bool requireClientCertificate: false});
162
163 /**
153 * Initializes the NSS library. If [initialize] is not called, the library 164 * Initializes the NSS library. If [initialize] is not called, the library
154 * is automatically initialized as if [initialize] were called with no 165 * is automatically initialized as if [initialize] were called with no
155 * arguments. If [initialize] is called more than once, or called after 166 * arguments. If [initialize] is called more than once, or called after
156 * automatic initialization has happened (when a secure connection is made), 167 * automatic initialization has happened (when a secure connection is made),
157 * then a TlsException is thrown. 168 * then a TlsException is thrown.
158 * 169 *
159 * The optional argument [database] is the path to a certificate database 170 * The optional argument [database] is the path to a certificate database
160 * directory containing root certificates for verifying certificate paths on 171 * directory containing root certificates for verifying certificate paths on
161 * client connections, and server certificates to provide on server 172 * client connections, and server certificates to provide on server
162 * connections. The argument [password] should be used when creating 173 * connections. The argument [password] should be used when creating
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 certificateName, 338 certificateName,
328 is_server: true, 339 is_server: true,
329 socket: socket, 340 socket: socket,
330 subscription: subscription, 341 subscription: subscription,
331 bufferedData: bufferedData, 342 bufferedData: bufferedData,
332 requestClientCertificate: requestClientCertificate, 343 requestClientCertificate: requestClientCertificate,
333 requireClientCertificate: requireClientCertificate); 344 requireClientCertificate: requireClientCertificate);
334 } 345 }
335 346
336 /** 347 /**
348 * Renegotiate an existing secure connection, renewing the session keys
349 * and possibly changing the connection properties.
350 *
351 * This repeats the SSL or TLS handshake, with options that allow clearing
352 * the session cache and requesting a client certificate.
353 */
354 void renegotiate({bool useSessionCache: true,
355 bool requestClientCertificate: false,
356 bool requireClientCertificate: false});
357
358 /**
337 * Get the peer certificate for a connected RawSecureSocket. If this 359 * Get the peer certificate for a connected RawSecureSocket. If this
338 * RawSecureSocket is the server end of a secure socket connection, 360 * RawSecureSocket is the server end of a secure socket connection,
339 * [peerCertificate] will return the client certificate, or null, if no 361 * [peerCertificate] will return the client certificate, or null, if no
340 * client certificate was received. If it is the client end, 362 * client certificate was received. If it is the client end,
341 * [peerCertificate] will return the server's certificate. 363 * [peerCertificate] will return the server's certificate.
342 */ 364 */
343 X509Certificate get peerCertificate; 365 X509Certificate get peerCertificate;
344 } 366 }
345 367
346 368
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 _secureFilter.handshake(); 800 _secureFilter.handshake();
779 _filterStatus.writeEmpty = false; 801 _filterStatus.writeEmpty = false;
780 _readSocket(); 802 _readSocket();
781 _writeSocket(); 803 _writeSocket();
782 _scheduleFilter(); 804 _scheduleFilter();
783 } catch (e) { 805 } catch (e) {
784 _reportError(e); 806 _reportError(e);
785 } 807 }
786 } 808 }
787 809
810 void renegotiate({bool useSessionCache: true,
811 bool requestClientCertificate: false,
812 bool requireClientCertificate: false}) {
813 try {
814 if (_status != CONNECTED) {
Anders Johnsen 2013/07/11 11:20:32 I would expect this to be a StateError thrown dire
Bill Hesse 2013/07/11 15:25:42 Done.
815 throw new HandshakeException(
816 "Called renegotiate on a non-connected socket");
817 }
818 _secureFilter.renegotiate(useSessionCache,
819 requestClientCertificate,
820 requireClientCertificate);
821 _status = HANDSHAKE;
822 _filterStatus.writeEmpty = false;
823 _scheduleFilter();
824 } catch (e) {
825 _reportError(e);
826 }
827 }
828
788 void _secureHandshakeCompleteHandler() { 829 void _secureHandshakeCompleteHandler() {
789 _status = CONNECTED; 830 _status = CONNECTED;
790 if (_connectPending) { 831 if (_connectPending) {
791 _connectPending = false; 832 _connectPending = false;
792 // We don't want user code to run synchronously in this callback. 833 // We don't want user code to run synchronously in this callback.
793 Timer.run(() => _handshakeComplete.complete(this)); 834 Timer.run(() => _handshakeComplete.complete(this));
794 } 835 }
795 } 836 }
796 837
797 void _onPauseStateChange() { 838 void _onPauseStateChange() {
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 void connect(String hostName, 1192 void connect(String hostName,
1152 Uint8List addr, 1193 Uint8List addr,
1153 int port, 1194 int port,
1154 bool is_server, 1195 bool is_server,
1155 String certificateName, 1196 String certificateName,
1156 bool requestClientCertificate, 1197 bool requestClientCertificate,
1157 bool requireClientCertificate, 1198 bool requireClientCertificate,
1158 bool sendClientCertificate); 1199 bool sendClientCertificate);
1159 void destroy(); 1200 void destroy();
1160 void handshake(); 1201 void handshake();
1202 void rehandshake();
1203 void renegotiate(bool useSessionCache,
1204 bool requestClientCertificate,
1205 bool requireClientCertificate);
1161 void init(); 1206 void init();
1162 X509Certificate get peerCertificate; 1207 X509Certificate get peerCertificate;
1163 int processBuffer(int bufferIndex); 1208 int processBuffer(int bufferIndex);
1164 void registerBadCertificateCallback(Function callback); 1209 void registerBadCertificateCallback(Function callback);
1165 void registerHandshakeCompleteCallback(Function handshakeCompleteHandler); 1210 void registerHandshakeCompleteCallback(Function handshakeCompleteHandler);
1166 int _pointer(); 1211 int _pointer();
1167 1212
1168 List<_ExternalBuffer> get buffers; 1213 List<_ExternalBuffer> get buffers;
1169 } 1214 }
1170 1215
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 /** 1259 /**
1215 * An exception that happens in the handshake phase of establishing 1260 * An exception that happens in the handshake phase of establishing
1216 * a secure network connection, when looking up or verifying a 1261 * a secure network connection, when looking up or verifying a
1217 * certificate. 1262 * certificate.
1218 */ 1263 */
1219 class CertificateException extends TlsException { 1264 class CertificateException extends TlsException {
1220 const CertificateException([String message = "", 1265 const CertificateException([String message = "",
1221 OSError osError = null]) 1266 OSError osError = null])
1222 : super._("CertificateException", message, osError); 1267 : super._("CertificateException", message, osError);
1223 } 1268 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698