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

Unified Diff: sdk/lib/io/secure_socket.dart

Issue 13502004: Add the ability to secure an already established raw socket connection (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed debug print Created 7 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/io/secure_socket.dart
diff --git a/sdk/lib/io/secure_socket.dart b/sdk/lib/io/secure_socket.dart
index 41fdf59a81d0a1c8e77f8432e5a925d4c7978167..58119a2d2af55b67311ef0925ed622c766b74070 100644
--- a/sdk/lib/io/secure_socket.dart
+++ b/sdk/lib/io/secure_socket.dart
@@ -144,6 +144,61 @@ abstract class RawSecureSocket implements RawSocket {
}
/**
+ * Takes an already connected [socket] and starts client side TLS
+ * handshake to make the communication secure. When the returned
+ * future completes the [RawSecureSocket] has completed the TLS
+ * handshake. Using this function requires that the other end of the
+ * connection is prepared for TLS handshake.
+ *
+ * See [connect] for more information on the arguments.
+ *
+ * Make sure that any subscription for [RawSocketEvent] evnets on
Mads Ager (google) 2013/04/03 15:26:55 evnets -> events.
Søren Gjesse 2013/04/19 05:17:09 Done
+ * the [socket] is canceled before calling this function.
Mads Ager (google) 2013/04/03 15:26:55 cancelled
Søren Gjesse 2013/04/19 05:17:09 Done.
+ */
+ static Future<RawSecureSocket> secure(
+ RawSocket socket,
+ {bool sendClientCertificate: false,
+ String certificateName,
+ bool onBadCertificate(X509Certificate certificate)}) {
+ return _RawSecureSocket.connect(
+ socket.host,
+ socket.port,
+ certificateName,
+ is_server: false,
+ socket: socket,
+ sendClientCertificate: sendClientCertificate,
+ onBadCertificate: onBadCertificate);
+ }
+
+ /**
+ * Takes an already connected [socket] and starts server side TLS
+ * handshake to make the communication secure. When the returned
+ * future completes the [RawSecureSocket] has completed the TLS
+ * handshake. Using this function requires that the other end of the
+ * connection is going to start the TLS handshake.
+ *
+ * See [RawSecureServerSocket.bind] for more information on the
+ * arguments.
+ *
+ * Make sure that any subscription for [RawSocketEvent] evnets on
+ * the [socket] is cancled before calling this function.
+ */
+ static Future<RawSecureSocket> secureServer(
+ RawSocket socket,
+ String certificateName,
+ {bool requestClientCertificate: false,
+ bool requireClientCertificate: false}) {
+ return _RawSecureSocket.connect(
+ socket.remoteHost,
+ socket.remotePort,
+ certificateName,
+ is_server: true,
+ socket: socket,
+ requestClientCertificate: requestClientCertificate,
+ requireClientCertificate: requireClientCertificate);
+ }
+
+ /**
* Get the peer certificate for a connected RawSecureSocket. If this
* RawSecureSocket is the server end of a secure socket connection,
* [peerCertificate] will return the client certificate, or null, if no

Powered by Google App Engine
This is Rietveld 408576698