Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 return _RawSecureSocket.connect( | 137 return _RawSecureSocket.connect( |
| 138 host, | 138 host, |
| 139 port, | 139 port, |
| 140 certificateName, | 140 certificateName, |
| 141 is_server: false, | 141 is_server: false, |
| 142 sendClientCertificate: sendClientCertificate, | 142 sendClientCertificate: sendClientCertificate, |
| 143 onBadCertificate: onBadCertificate); | 143 onBadCertificate: onBadCertificate); |
| 144 } | 144 } |
| 145 | 145 |
| 146 /** | 146 /** |
| 147 * Takes an already connected [socket] and starts client side TLS | |
| 148 * handshake to make the communication secure. When the returned | |
| 149 * future completes the [RawSecureSocket] has completed the TLS | |
| 150 * handshake. Using this function requires that the other end of the | |
| 151 * connection is prepared for TLS handshake. | |
| 152 * | |
| 153 * See [connect] for more information on the arguments. | |
| 154 * | |
| 155 * 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
| |
| 156 * 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.
| |
| 157 */ | |
| 158 static Future<RawSecureSocket> secure( | |
| 159 RawSocket socket, | |
| 160 {bool sendClientCertificate: false, | |
| 161 String certificateName, | |
| 162 bool onBadCertificate(X509Certificate certificate)}) { | |
| 163 return _RawSecureSocket.connect( | |
| 164 socket.host, | |
| 165 socket.port, | |
| 166 certificateName, | |
| 167 is_server: false, | |
| 168 socket: socket, | |
| 169 sendClientCertificate: sendClientCertificate, | |
| 170 onBadCertificate: onBadCertificate); | |
| 171 } | |
| 172 | |
| 173 /** | |
| 174 * Takes an already connected [socket] and starts server side TLS | |
| 175 * handshake to make the communication secure. When the returned | |
| 176 * future completes the [RawSecureSocket] has completed the TLS | |
| 177 * handshake. Using this function requires that the other end of the | |
| 178 * connection is going to start the TLS handshake. | |
| 179 * | |
| 180 * See [RawSecureServerSocket.bind] for more information on the | |
| 181 * arguments. | |
| 182 * | |
| 183 * Make sure that any subscription for [RawSocketEvent] evnets on | |
| 184 * the [socket] is cancled before calling this function. | |
| 185 */ | |
| 186 static Future<RawSecureSocket> secureServer( | |
| 187 RawSocket socket, | |
| 188 String certificateName, | |
| 189 {bool requestClientCertificate: false, | |
| 190 bool requireClientCertificate: false}) { | |
| 191 return _RawSecureSocket.connect( | |
| 192 socket.remoteHost, | |
| 193 socket.remotePort, | |
| 194 certificateName, | |
| 195 is_server: true, | |
| 196 socket: socket, | |
| 197 requestClientCertificate: requestClientCertificate, | |
| 198 requireClientCertificate: requireClientCertificate); | |
| 199 } | |
| 200 | |
| 201 /** | |
| 147 * Get the peer certificate for a connected RawSecureSocket. If this | 202 * Get the peer certificate for a connected RawSecureSocket. If this |
| 148 * RawSecureSocket is the server end of a secure socket connection, | 203 * RawSecureSocket is the server end of a secure socket connection, |
| 149 * [peerCertificate] will return the client certificate, or null, if no | 204 * [peerCertificate] will return the client certificate, or null, if no |
| 150 * client certificate was received. If it is the client end, | 205 * client certificate was received. If it is the client end, |
| 151 * [peerCertificate] will return the server's certificate. | 206 * [peerCertificate] will return the server's certificate. |
| 152 */ | 207 */ |
| 153 X509Certificate get peerCertificate; | 208 X509Certificate get peerCertificate; |
| 154 } | 209 } |
| 155 | 210 |
| 156 | 211 |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 753 void destroy(); | 808 void destroy(); |
| 754 void handshake(); | 809 void handshake(); |
| 755 void init(); | 810 void init(); |
| 756 X509Certificate get peerCertificate; | 811 X509Certificate get peerCertificate; |
| 757 int processBuffer(int bufferIndex); | 812 int processBuffer(int bufferIndex); |
| 758 void registerBadCertificateCallback(Function callback); | 813 void registerBadCertificateCallback(Function callback); |
| 759 void registerHandshakeCompleteCallback(Function handshakeCompleteHandler); | 814 void registerHandshakeCompleteCallback(Function handshakeCompleteHandler); |
| 760 | 815 |
| 761 List<_ExternalBuffer> get buffers; | 816 List<_ExternalBuffer> get buffers; |
| 762 } | 817 } |
| OLD | NEW |