diff options
author | Giampaolo RodolĂ <g.rodola@gmail.com> | 2010-08-29 19:25:49 +0000 |
---|---|---|
committer | Giampaolo RodolĂ <g.rodola@gmail.com> | 2010-08-29 19:25:49 +0000 |
commit | b24063df2d61005f7805c41636aca7858a1fea8c (patch) | |
tree | a8459287e052c7251d3e9cc6ce623ff8a952e8eb /Lib/ssl.py | |
parent | a53f28c068f156d88b916b51e799a9d8ff882e90 (diff) | |
download | cpython-b24063df2d61005f7805c41636aca7858a1fea8c.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.py | 8 |
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: |