Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
create_ssl_context: raw socket
  • Loading branch information
dsiroky committed Jun 8, 2016
1 parent c3e6d29 commit 1c34bb7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions snakemq/link.py
Expand Up @@ -176,16 +176,17 @@ def close(self):

def create_ssl_context(self):
assert isinstance(self.sock, ssl.SSLSocket)

if hasattr(self.sock, "_sock"):
raw_sock = self.sock._sock # py2
else:
raw_sock = self.sock # py3

# this is always called from handle_connect so server_side=False
if hasattr(self.sock, "context"):
# py3.2
self.sock._sslobj = self.sock.context._wrap_socket(self.sock,
self.sock._sslobj = self.sock.context._wrap_socket(raw_sock,
False, None)
else:
if hasattr(self.sock, "_sock"):
raw_sock = self.sock._sock # py2
else:
raw_sock = self.sock # py3.1
self.sock._sslobj = ssl._ssl.sslwrap(raw_sock, False,
self.sock.keyfile, self.sock.certfile,
self.sock.cert_reqs, self.sock.ssl_version,
Expand Down

0 comments on commit 1c34bb7

Please sign in to comment.