| 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 12 matching lines...) Expand all Loading... |
| 23 * The default SecurityContext object contains a built-in set of trusted | 23 * The default SecurityContext object contains a built-in set of trusted |
| 24 * root certificates for well-known certificate authorities. | 24 * root certificates for well-known certificate authorities. |
| 25 * | 25 * |
| 26 * [onBadCertificate] is an optional handler for unverifiable certificates. | 26 * [onBadCertificate] is an optional handler for unverifiable certificates. |
| 27 * The handler receives the [X509Certificate], and can inspect it and | 27 * The handler receives the [X509Certificate], and can inspect it and |
| 28 * decide (or let the user decide) whether to accept | 28 * decide (or let the user decide) whether to accept |
| 29 * the connection or not. The handler should return true | 29 * the connection or not. The handler should return true |
| 30 * to continue the [SecureSocket] connection. | 30 * to continue the [SecureSocket] connection. |
| 31 * | 31 * |
| 32 * [supportedProtocols] is an optional list of protocols (in decreasing | 32 * [supportedProtocols] is an optional list of protocols (in decreasing |
| 33 * order of preference) to use during the ALPN protocol negogiation with the | 33 * order of preference) to use during the ALPN protocol negotiation with the |
| 34 * server. Example values are "http/1.1" or "h2". The selected protocol | 34 * server. Example values are "http/1.1" or "h2". The selected protocol |
| 35 * can be obtained via [SecureSocket.selectedProtocol]. | 35 * can be obtained via [SecureSocket.selectedProtocol]. |
| 36 */ | 36 */ |
| 37 static Future<SecureSocket> connect(host, int port, | 37 static Future<SecureSocket> connect(host, int port, |
| 38 {SecurityContext context, | 38 {SecurityContext context, |
| 39 bool onBadCertificate(X509Certificate certificate), | 39 bool onBadCertificate(X509Certificate certificate), |
| 40 List<String> supportedProtocols}) { | 40 List<String> supportedProtocols}) { |
| 41 return RawSecureSocket | 41 return RawSecureSocket |
| 42 .connect(host, port, | 42 .connect(host, port, |
| 43 context: context, | 43 context: context, |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 * [SecurityContext.usePrivateKey], and the server asks for a client | 180 * [SecurityContext.usePrivateKey], and the server asks for a client |
| 181 * certificate, then that client certificate is sent to the server. | 181 * certificate, then that client certificate is sent to the server. |
| 182 * | 182 * |
| 183 * [onBadCertificate] is an optional handler for unverifiable certificates. | 183 * [onBadCertificate] is an optional handler for unverifiable certificates. |
| 184 * The handler receives the [X509Certificate], and can inspect it and | 184 * The handler receives the [X509Certificate], and can inspect it and |
| 185 * decide (or let the user decide) whether to accept | 185 * decide (or let the user decide) whether to accept |
| 186 * the connection or not. The handler should return true | 186 * the connection or not. The handler should return true |
| 187 * to continue the [RawSecureSocket] connection. | 187 * to continue the [RawSecureSocket] connection. |
| 188 * | 188 * |
| 189 * [supportedProtocols] is an optional list of protocols (in decreasing | 189 * [supportedProtocols] is an optional list of protocols (in decreasing |
| 190 * order of preference) to use during the ALPN protocol negogiation with the | 190 * order of preference) to use during the ALPN protocol negotiation with the |
| 191 * server. Example values are "http/1.1" or "h2". The selected protocol | 191 * server. Example values are "http/1.1" or "h2". The selected protocol |
| 192 * can be obtained via [RawSecureSocket.selectedProtocol]. | 192 * can be obtained via [RawSecureSocket.selectedProtocol]. |
| 193 */ | 193 */ |
| 194 static Future<RawSecureSocket> connect(host, int port, | 194 static Future<RawSecureSocket> connect(host, int port, |
| 195 {SecurityContext context, | 195 {SecurityContext context, |
| 196 bool onBadCertificate(X509Certificate certificate), | 196 bool onBadCertificate(X509Certificate certificate), |
| 197 List<String> supportedProtocols}) { | 197 List<String> supportedProtocols}) { |
| 198 _RawSecureSocket._verifyFields( | 198 _RawSecureSocket._verifyFields( |
| 199 host, port, false, false, false, onBadCertificate); | 199 host, port, false, false, false, onBadCertificate); |
| 200 return RawSocket.connect(host, port).then((socket) { | 200 return RawSocket.connect(host, port).then((socket) { |
| (...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 | 1229 |
| 1230 /** | 1230 /** |
| 1231 * An exception that happens in the handshake phase of establishing | 1231 * An exception that happens in the handshake phase of establishing |
| 1232 * a secure network connection, when looking up or verifying a | 1232 * a secure network connection, when looking up or verifying a |
| 1233 * certificate. | 1233 * certificate. |
| 1234 */ | 1234 */ |
| 1235 class CertificateException extends TlsException { | 1235 class CertificateException extends TlsException { |
| 1236 const CertificateException([String message = "", OSError osError = null]) | 1236 const CertificateException([String message = "", OSError osError = null]) |
| 1237 : super._("CertificateException", message, osError); | 1237 : super._("CertificateException", message, osError); |
| 1238 } | 1238 } |
| OLD | NEW |