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 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 args[0] = _filterPointer; | 963 args[0] = _filterPointer; |
964 args[1] = wasInHandshake; | 964 args[1] = wasInHandshake; |
965 var bufs = _secureFilter.buffers; | 965 var bufs = _secureFilter.buffers; |
966 for (var i = 0; i < NUM_BUFFERS; ++i) { | 966 for (var i = 0; i < NUM_BUFFERS; ++i) { |
967 args[2 * i + 2] = bufs[i].start; | 967 args[2 * i + 2] = bufs[i].start; |
968 args[2 * i + 3] = bufs[i].end; | 968 args[2 * i + 3] = bufs[i].end; |
969 } | 969 } |
970 | 970 |
971 return _IOService._dispatch(_SSL_PROCESS_FILTER, args).then((response) { | 971 return _IOService._dispatch(_SSL_PROCESS_FILTER, args).then((response) { |
972 if (response.length == 2) { | 972 if (response.length == 2) { |
973 _reportError(new TlsException('${response[1]} error ${response[0]}'), | 973 if (wasInHandshake) { |
974 null); | 974 // If we're in handshake, throw a handshake error. |
| 975 _reportError( |
| 976 new HandshakeException('${response[1]} error ${response[0]}'), |
| 977 null); |
| 978 } else { |
| 979 // If we're connected, throw a TLS error. |
| 980 _reportError(new TlsException('${response[1]} error ${response[0]}'), |
| 981 null); |
| 982 } |
975 } | 983 } |
976 int start(int index) => response[2 * index]; | 984 int start(int index) => response[2 * index]; |
977 int end(int index) => response[2 * index + 1]; | 985 int end(int index) => response[2 * index + 1]; |
978 | 986 |
979 _FilterStatus status = new _FilterStatus(); | 987 _FilterStatus status = new _FilterStatus(); |
980 // Compute writeEmpty as "write plaintext buffer and write encrypted | 988 // Compute writeEmpty as "write plaintext buffer and write encrypted |
981 // buffer were empty when we started and are empty now". | 989 // buffer were empty when we started and are empty now". |
982 status.writeEmpty = bufs[WRITE_PLAINTEXT].isEmpty && | 990 status.writeEmpty = bufs[WRITE_PLAINTEXT].isEmpty && |
983 start(WRITE_ENCRYPTED) == end(WRITE_ENCRYPTED); | 991 start(WRITE_ENCRYPTED) == end(WRITE_ENCRYPTED); |
984 // If we were in handshake when this started, _writeEmpty may be false | 992 // If we were in handshake when this started, _writeEmpty may be false |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 /** | 1234 /** |
1227 * An exception that happens in the handshake phase of establishing | 1235 * An exception that happens in the handshake phase of establishing |
1228 * a secure network connection, when looking up or verifying a | 1236 * a secure network connection, when looking up or verifying a |
1229 * certificate. | 1237 * certificate. |
1230 */ | 1238 */ |
1231 class CertificateException extends TlsException { | 1239 class CertificateException extends TlsException { |
1232 const CertificateException([String message = "", | 1240 const CertificateException([String message = "", |
1233 OSError osError = null]) | 1241 OSError osError = null]) |
1234 : super._("CertificateException", message, osError); | 1242 : super._("CertificateException", message, osError); |
1235 } | 1243 } |
OLD | NEW |