From 8f8796f9d9d49e1e968cb8c48b09f26b2a11dcb2 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 8 Feb 2016 00:40:55 +0100 Subject: expose OpenSSL's HAS_ALPN --- netlib/tcp.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'netlib') diff --git a/netlib/tcp.py b/netlib/tcp.py index 682db29a..85b4b0e2 100644 --- a/netlib/tcp.py +++ b/netlib/tcp.py @@ -31,6 +31,7 @@ else: socket_fileobject = socket.SocketIO EINTR = 4 +HAS_ALPN = OpenSSL._util.lib.Cryptography_HAS_ALPN # To enable all SSL methods use: SSLv23 # then add options to disable certain methods @@ -542,7 +543,7 @@ class _Connection(object): if log_ssl_key: context.set_info_callback(log_ssl_key) - if OpenSSL._util.lib.Cryptography_HAS_ALPN: + if HAS_ALPN: if alpn_protos is not None: # advertise application layer protocols context.set_alpn_protos(alpn_protos) @@ -696,7 +697,7 @@ class TCPClient(_Connection): return self.connection.gettimeout() def get_alpn_proto_negotiated(self): - if OpenSSL._util.lib.Cryptography_HAS_ALPN and self.ssl_established: + if HAS_ALPN and self.ssl_established: return self.connection.get_alpn_proto_negotiated() else: return b"" @@ -802,7 +803,7 @@ class BaseHandler(_Connection): self.connection.settimeout(n) def get_alpn_proto_negotiated(self): - if OpenSSL._util.lib.Cryptography_HAS_ALPN and self.ssl_established: + if HAS_ALPN and self.ssl_established: return self.connection.get_alpn_proto_negotiated() else: return b"" -- cgit v1.2.3