blob: 3edf243ff5e8d2ce3a467c9b51c949aa6ff247fe [file] [log] [blame]
Brad Bishope4ad8282016-06-09 00:31:32 -04001--- a/gevent/ssl.py 2015-03-13 05:44:39.000000000 +0800
2+++ b/gevent/ssl.py 2015-03-13 05:44:24.000000000 +0800
3@@ -19,6 +19,25 @@
4 except AttributeError:
5 _ssl = __ssl__._ssl2
6
7+import inspect
8+
9+
10+def new_sslwrap(sock, server_side=False, keyfile=None, certfile=None, cert_reqs=__ssl__.CERT_NONE, ssl_version=__ssl__.PROTOCOL_SSLv23, ca_certs=None, ciphers=None):
11+ context = __ssl__.SSLContext(ssl_version)
12+ context.verify_mode = cert_reqs or __ssl__.CERT_NONE
13+ if ca_certs:
14+ context.load_verify_locations(ca_certs)
15+ if certfile:
16+ context.load_cert_chain(certfile, keyfile)
17+ if ciphers:
18+ context.set_ciphers(ciphers)
19+
20+ caller_self = inspect.currentframe().f_back.f_locals['self']
21+ return context._wrap_socket(sock, server_side=server_side, ssl_sock=caller_self)
22+
23+if not hasattr(_ssl, 'sslwrap'):
24+ _ssl.sslwrap = new_sslwrap
25+
26 import sys
27 import errno
28 from gevent.socket import socket, _fileobject, timeout_default