diff options
author | Jean-Paul Calderone <jean-paul@clusterhq.com> | 2015-01-13 08:21:23 -0500 |
---|---|---|
committer | Jean-Paul Calderone <jean-paul@clusterhq.com> | 2015-01-13 08:21:23 -0500 |
commit | 014c0cc45915a73be8a9c43e70dae760f1b44237 (patch) | |
tree | 5659baa28f3aae6f14932ee593d0a47a2bf80287 | |
parent | 7b31baf7d362a095951e733b38b36fbd07e6d8bd (diff) | |
parent | 306b75ab0d8959e8bfb21bdad831a5610609afaa (diff) | |
download | pyopenssl-014c0cc45915a73be8a9c43e70dae760f1b44237.tar.gz |
Merge pull request #183 from darkrain42/Connection.shutdown-errors
Fix error handling in Connection.shutdown.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | OpenSSL/SSL.py | 3 | ||||
-rw-r--r-- | OpenSSL/test/test_ssl.py | 14 |
3 files changed, 20 insertions, 2 deletions
@@ -1,3 +1,8 @@ +2015-01-08 Paul Aurich <paul@darkrain42.org> + + * OpenSSL/SSL.py: ``Connection.shutdown`` now propagates errors from the + underlying socket. + 2014-08-21 Alex Gaynor <alex.gaynor@gmail.com> * OpenSSL/crypto.py: Fixed a regression where calling ``load_pkcs7_data`` diff --git a/OpenSSL/SSL.py b/OpenSSL/SSL.py index 7b1cbc1..b6c8076 100644 --- a/OpenSSL/SSL.py +++ b/OpenSSL/SSL.py @@ -1183,8 +1183,7 @@ class Connection(object): """ result = _lib.SSL_shutdown(self._ssl) if result < 0: - # TODO: This is untested. - _raise_current_error() + self._raise_ssl_error(self._ssl, result) elif result > 0: return True else: diff --git a/OpenSSL/test/test_ssl.py b/OpenSSL/test/test_ssl.py index 44980d5..79010fb 100644 --- a/OpenSSL/test/test_ssl.py +++ b/OpenSSL/test/test_ssl.py @@ -1709,6 +1709,20 @@ class ConnectionTests(TestCase, _LoopbackMixin): self.assertEquals(server.get_shutdown(), SENT_SHUTDOWN|RECEIVED_SHUTDOWN) + def test_shutdown_closed(self): + """ + If the underlying socket is closed, :py:obj:`Connection.shutdown` propagates the + write error from the low level write call. + """ + server, client = self._loopback() + server.sock_shutdown(2) + exc = self.assertRaises(SysCallError, server.shutdown) + if platform == "win32": + self.assertEqual(exc.args[0], ESHUTDOWN) + else: + self.assertEqual(exc.args[0], EPIPE) + + def test_set_shutdown(self): """ :py:obj:`Connection.set_shutdown` sets the state of the SSL connection shutdown |