| 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 * decide (or let the user decide) whether to accept | 239 * decide (or let the user decide) whether to accept |
| 240 * the connection or not. The handler should return true | 240 * the connection or not. The handler should return true |
| 241 * to continue the [RawSecureSocket] connection. | 241 * to continue the [RawSecureSocket] connection. |
| 242 */ | 242 */ |
| 243 static Future<RawSecureSocket> connect( | 243 static Future<RawSecureSocket> connect( |
| 244 host, | 244 host, |
| 245 int port, | 245 int port, |
| 246 {bool sendClientCertificate: false, | 246 {bool sendClientCertificate: false, |
| 247 String certificateName, | 247 String certificateName, |
| 248 bool onBadCertificate(X509Certificate certificate)}) { | 248 bool onBadCertificate(X509Certificate certificate)}) { |
| 249 return _RawSecureSocket.connect( | 249 _RawSecureSocket._verifyFields( |
| 250 host, | 250 host, |
| 251 port, | 251 port, |
| 252 certificateName, | 252 certificateName, |
| 253 is_server: false, | 253 false, |
| 254 sendClientCertificate: sendClientCertificate, | 254 false, |
| 255 onBadCertificate: onBadCertificate); | 255 false, |
| 256 sendClientCertificate, |
| 257 onBadCertificate); |
| 258 return RawSocket.connect(host, port) |
| 259 .then((socket) { |
| 260 return secure(socket, |
| 261 host: host, |
| 262 sendClientCertificate: sendClientCertificate, |
| 263 certificateName: certificateName, |
| 264 onBadCertificate: onBadCertificate); |
| 265 }); |
| 256 } | 266 } |
| 257 | 267 |
| 258 /** | 268 /** |
| 259 * Takes an already connected [socket] and starts client side TLS | 269 * Takes an already connected [socket] and starts client side TLS |
| 260 * handshake to make the communication secure. When the returned | 270 * handshake to make the communication secure. When the returned |
| 261 * future completes the [RawSecureSocket] has completed the TLS | 271 * future completes the [RawSecureSocket] has completed the TLS |
| 262 * handshake. Using this function requires that the other end of the | 272 * handshake. Using this function requires that the other end of the |
| 263 * connection is prepared for TLS handshake. | 273 * connection is prepared for TLS handshake. |
| 264 * | 274 * |
| 265 * If the [socket] already has a subscription, pass the existing | 275 * If the [socket] already has a subscription, pass the existing |
| (...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 /** | 1278 /** |
| 1269 * An exception that happens in the handshake phase of establishing | 1279 * An exception that happens in the handshake phase of establishing |
| 1270 * a secure network connection, when looking up or verifying a | 1280 * a secure network connection, when looking up or verifying a |
| 1271 * certificate. | 1281 * certificate. |
| 1272 */ | 1282 */ |
| 1273 class CertificateException extends TlsException { | 1283 class CertificateException extends TlsException { |
| 1274 const CertificateException([String message = "", | 1284 const CertificateException([String message = "", |
| 1275 OSError osError = null]) | 1285 OSError osError = null]) |
| 1276 : super._("CertificateException", message, osError); | 1286 : super._("CertificateException", message, osError); |
| 1277 } | 1287 } |
| OLD | NEW |