From ca46b1e340750859881347ead92a64ed05105d25 Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Wed, 17 May 2017 10:38:31 +0800 Subject: [PATCH] alpn_select_callback must be a callable --- mitmproxy/net/tcp.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mitmproxy/net/tcp.py b/mitmproxy/net/tcp.py index b4c4ac647..76944b8ba 100644 --- a/mitmproxy/net/tcp.py +++ b/mitmproxy/net/tcp.py @@ -524,9 +524,11 @@ class _Connection: return options[0] context.set_alpn_select_callback(alpn_select_callback) elif alpn_select_callback is not None and alpn_select is None: + if not callable(alpn_select_callback): + raise exceptions.TlsException("ALPN error: alpn_select_callback must be a function.") context.set_alpn_select_callback(alpn_select_callback) elif alpn_select_callback is not None and alpn_select is not None: - raise exceptions.TlsException("ALPN error: only define alpn_select (string) OR alpn_select_callback (method).") + raise exceptions.TlsException("ALPN error: only define alpn_select (string) OR alpn_select_callback (function).") return context