summaryrefslogtreecommitdiffstats
path: root/Lib/ssl.py
diff options
context:
space:
mode:
authorBill Janssen <janssen@parc.com>2008-09-29 18:56:38 (GMT)
committerBill Janssen <janssen@parc.com>2008-09-29 18:56:38 (GMT)
commiteb257ac97ddcb477893a962318219af0871d4b93 (patch)
treef02a8cf664783d15a63689404545f776394fac10 /Lib/ssl.py
parent9350234683d5f5b2523911d7f585d4420e30924d (diff)
downloadcpython-eb257ac97ddcb477893a962318219af0871d4b93.zip
cpython-eb257ac97ddcb477893a962318219af0871d4b93.tar.gz
cpython-eb257ac97ddcb477893a962318219af0871d4b93.tar.bz2
fix for release blocker 3910, 2.6 regression in socket.ssl method
Diffstat (limited to 'Lib/ssl.py')
-rw-r--r--Lib/ssl.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/Lib/ssl.py b/Lib/ssl.py
index 8a799bc..21ae405 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -434,7 +434,18 @@ def sslwrap_simple (sock, keyfile=None, certfile=None):
for compability with Python 2.5 and earlier. Will disappear in
Python 3.0."""
- ssl_sock = _ssl.sslwrap(sock._sock, 0, keyfile, certfile, CERT_NONE,
+ if hasattr(sock, "_sock"):
+ sock = sock._sock
+
+ ssl_sock = _ssl.sslwrap(sock, 0, keyfile, certfile, CERT_NONE,
PROTOCOL_SSLv23, None)
- ssl_sock.do_handshake()
+ try:
+ sock.getpeername()
+ except:
+ # no, no connection yet
+ pass
+ else:
+ # yes, do the handshake
+ ssl_sock.do_handshake()
+
return ssl_sock