summaryrefslogtreecommitdiff
path: root/Lib/ssl.py
diff options
context:
space:
mode:
authorGiampaolo RodolĂ  <g.rodola@gmail.com>2010-08-29 19:25:49 +0000
committerGiampaolo RodolĂ  <g.rodola@gmail.com>2010-08-29 19:25:49 +0000
commit745ab3807e0c5f141376f6b9e1b6111e806c31d0 (patch)
treeb4ef66f6bb731df7a6e869896cdee0f859990707 /Lib/ssl.py
parent374f835316251651ddfe7794c9db7afd94fb0ed4 (diff)
downloadcpython-git-745ab3807e0c5f141376f6b9e1b6111e806c31d0.tar.gz
Fix issue issue9706: provides a better error handling for various SSL operations
Diffstat (limited to 'Lib/ssl.py')
-rw-r--r--Lib/ssl.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/ssl.py b/Lib/ssl.py
index af1cc840a4..a634442e13 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -122,6 +122,9 @@ class SSLSocket(socket):
if _context:
self.context = _context
else:
+ if server_side and not certfile:
+ raise ValueError("certfile must be specified for server-side "
+ "operations")
if certfile and not keyfile:
keyfile = certfile
self.context = SSLContext(ssl_version)
@@ -138,7 +141,7 @@ class SSLSocket(socket):
self.ssl_version = ssl_version
self.ca_certs = ca_certs
self.ciphers = ciphers
-
+ self.server_side = server_side
self.do_handshake_on_connect = do_handshake_on_connect
self.suppress_ragged_eofs = suppress_ragged_eofs
connected = False
@@ -358,7 +361,8 @@ class SSLSocket(socket):
def connect(self, addr):
"""Connects to remote ADDR, and then wraps the connection in
an SSL channel."""
-
+ if self.server_side:
+ raise ValueError("can't connect in server-side mode")
# Here we assume that the socket is client-side, and not
# connected at the time of the call. We connect it, then wrap it.
if self._sslobj: