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

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

Issue 20316002: dart:io | Fix handling of exceptions from onBadCertificate callback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: try again Created 7 years, 5 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
« no previous file with comments | « runtime/bin/secure_socket.cc ('k') | tests/standalone/io/raw_secure_server_socket_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/secure_socket.dart
diff --git a/sdk/lib/io/secure_socket.dart b/sdk/lib/io/secure_socket.dart
index 6da8ec67348a4004e24d91cec986fce2a4eb6d30..874a234920dd661de6219d50316d0846203d4362 100644
--- a/sdk/lib/io/secure_socket.dart
+++ b/sdk/lib/io/secure_socket.dart
@@ -516,7 +516,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
_secureFilter.registerHandshakeCompleteCallback(
_secureHandshakeCompleteHandler);
if (onBadCertificate != null) {
- _secureFilter.registerBadCertificateCallback(onBadCertificate);
+ _secureFilter.registerBadCertificateCallback(_onBadCertificateWrapper);
}
var futureSocket;
if (socket == null) {
@@ -720,6 +720,14 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
X509Certificate get peerCertificate => _secureFilter.peerCertificate;
+ bool _onBadCertificateWrapper(X509Certificate certificate) {
+ if (onBadCertificate == null) return false;
+ var result = onBadCertificate(certificate);
+ if (result is bool) return result;
+ throw new ArgumentError(
+ "onBadCertificate callback returned non-boolean $result");
+ }
+
bool setOption(SocketOption option, bool enabled) {
if (_socket == null) return false;
return _socket.setOption(option, enabled);
@@ -761,9 +769,6 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
} else if (_connectPending) {
// _connectPending is true after the underlying connection has been
// made, but before the handshake has completed.
- if (e is! TlsException) {
- e = new HandshakeException("$e", null);
- }
_handshakeComplete.completeError(e);
} else {
_controller.addError(e);
« no previous file with comments | « runtime/bin/secure_socket.cc ('k') | tests/standalone/io/raw_secure_server_socket_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698