summaryrefslogtreecommitdiffstats
path: root/Lib/ssl.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-10-02 03:53:01 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-10-02 03:53:01 (GMT)
commit2f33456e41330abdd0e818802665a4e0091626a2 (patch)
tree757d97b750e39b5e63f471cccf4a3beea3f86dbd /Lib/ssl.py
parent0d377b371d8ec8bd538ed7325000e815d02cb03b (diff)
downloadcpython-2f33456e41330abdd0e818802665a4e0091626a2.zip
cpython-2f33456e41330abdd0e818802665a4e0091626a2.tar.gz
cpython-2f33456e41330abdd0e818802665a4e0091626a2.tar.bz2
fix sslwrap_simple (closes #22523)
Thanks Alex Gaynor.
Diffstat (limited to 'Lib/ssl.py')
-rw-r--r--Lib/ssl.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/ssl.py b/Lib/ssl.py
index 43c91a2..5bc07a7 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -969,16 +969,16 @@ def get_protocol_name(protocol_code):
# a replacement for the old socket.ssl function
def sslwrap_simple(sock, keyfile=None, certfile=None):
-
"""A replacement for the old socket.ssl function. Designed
for compability with Python 2.5 and earlier. Will disappear in
Python 3.0."""
-
if hasattr(sock, "_sock"):
sock = sock._sock
- ssl_sock = _ssl.sslwrap(sock, 0, keyfile, certfile, CERT_NONE,
- PROTOCOL_SSLv23, None)
+ ctx = SSLContext(PROTOCOL_SSLv23)
+ if keyfile or certfile:
+ ctx.load_cert_chain(certfile, keyfile)
+ ssl_sock = ctx._wrap_socket(sock, server_side=False)
try:
sock.getpeername()
except socket_error: