gevent: update Python 2.7.9 compatibility patch

(cherry picked from commit 0e0bc3ac86)
Signed-off-by: Domen Kožar <domen@dev.si>
This commit is contained in:
Domen Kožar 2015-03-07 19:28:55 +01:00
parent 2635bde9ee
commit 04be36e000

View File

@ -1,8 +1,17 @@
Index: b/gevent/ssl.py From 485cebc4d9bab2dae51cf29f91fad2f1cf157fec Mon Sep 17 00:00:00 2001
=================================================================== From: Eugene Pankov <john.pankov@gmail.com>
Date: Sun, 21 Sep 2014 12:04:13 +0300
Subject: [PATCH] Work around missing sslwrap in Python 2.7.9 (fixes #477)
---
gevent/_ssl2.py | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/gevent/ssl.py b/gevent/ssl.py
index 21491b7..85e6a86 100644
--- a/gevent/ssl.py --- a/gevent/ssl.py
+++ b/gevent/ssl.py +++ b/gevent/ssl.py
@@ -81,15 +81,14 @@ class SSLSocket(socket): @@ -80,15 +80,27 @@ def __init__(self, sock, keyfile=None, certfile=None,
self._sslobj = None self._sslobj = None
else: else:
# yes, create the SSL object # yes, create the SSL object
@ -10,19 +19,31 @@ Index: b/gevent/ssl.py
- self._sslobj = _ssl.sslwrap(self._sock, server_side, - self._sslobj = _ssl.sslwrap(self._sock, server_side,
- keyfile, certfile, - keyfile, certfile,
- cert_reqs, ssl_version, ca_certs) - cert_reqs, ssl_version, ca_certs)
- else: + if hasattr(_ssl, 'sslwrap'):
+ if ciphers is None:
+ self._sslobj = _ssl.sslwrap(self._sock, server_side,
+ keyfile, certfile,
+ cert_reqs, ssl_version, ca_certs)
+ else:
+ self._sslobj = _ssl.sslwrap(self._sock, server_side,
+ keyfile, certfile,
+ cert_reqs, ssl_version, ca_certs,
+ ciphers)
else:
- self._sslobj = _ssl.sslwrap(self._sock, server_side, - self._sslobj = _ssl.sslwrap(self._sock, server_side,
- keyfile, certfile, - keyfile, certfile,
- cert_reqs, ssl_version, ca_certs, - cert_reqs, ssl_version, ca_certs,
- ciphers) - ciphers)
+ ctx = __ssl__.SSLContext(ssl_version) + self.context = __ssl__.SSLContext(ssl_version)
+ if keyfile or certfile: + self.context.verify_mode = cert_reqs
+ ctx.load_cert_chain(certfile, keyfile) + if ca_certs:
+ if ca_certs: + self.context.load_verify_locations(ca_certs)
+ ctx.load_verify_locations(ca_certs) + if certfile:
+ if ciphers: + self.context.load_cert_chain(certfile, keyfile)
+ ctx.set_ciphers(ciphers) + if ciphers:
+ self._sslobj = ctx._wrap_socket(self._sock, server_side=server_side) + self.context.set_ciphers(ciphers)
+ self._sslobj = self.context._wrap_socket(self._sock, server_side=server_side, ssl_sock=self)
+
if do_handshake_on_connect: if do_handshake_on_connect:
self.do_handshake() self.do_handshake()
self.keyfile = keyfile self.keyfile = keyfile