Skip to content
This repository has been archived by the owner on Jun 1, 2018. It is now read-only.

Commit

Permalink
expose OpenSSL's HAS_ALPN
Browse files Browse the repository at this point in the history
  • Loading branch information
mhils committed Feb 7, 2016
1 parent cbee3bd commit 8f8796f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions netlib/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
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
Expand Down Expand Up @@ -542,7 +543,7 @@ def verify_cert(conn, x509, errno, err_depth, is_cert_verified):
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)
Expand Down Expand Up @@ -696,7 +697,7 @@ def gettimeout(self):
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""
Expand Down Expand Up @@ -802,7 +803,7 @@ def settimeout(self, n):
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""
Expand Down

0 comments on commit 8f8796f

Please sign in to comment.