| --- a/gevent/ssl.py 2015-03-13 05:44:39.000000000 +0800 |
| +++ b/gevent/ssl.py 2015-03-13 05:44:24.000000000 +0800 |
| @@ -19,6 +19,25 @@ |
| except AttributeError: |
| _ssl = __ssl__._ssl2 |
| |
| +import inspect |
| + |
| + |
| +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): |
| + context = __ssl__.SSLContext(ssl_version) |
| + context.verify_mode = cert_reqs or __ssl__.CERT_NONE |
| + if ca_certs: |
| + context.load_verify_locations(ca_certs) |
| + if certfile: |
| + context.load_cert_chain(certfile, keyfile) |
| + if ciphers: |
| + context.set_ciphers(ciphers) |
| + |
| + caller_self = inspect.currentframe().f_back.f_locals['self'] |
| + return context._wrap_socket(sock, server_side=server_side, ssl_sock=caller_self) |
| + |
| +if not hasattr(_ssl, 'sslwrap'): |
| + _ssl.sslwrap = new_sslwrap |
| + |
| import sys |
| import errno |
| from gevent.socket import socket, _fileobject, timeout_default |