summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Paul Calderone <exarkun@twistedmatrix.com>2014-02-12 10:11:49 -0500
committerJean-Paul Calderone <exarkun@twistedmatrix.com>2014-02-12 10:11:49 -0500
commit221e990f2c0d9055626cb929b8560c0c250ecb4b (patch)
tree1c82de6187ae3c371a35724da171658c212f8203
parent970631432039ea05b0a67e208780753023b8e8ad (diff)
parent3835e52f89ecaa7c7c9ab18872d19a758e449135 (diff)
downloadpyopenssl-221e990f2c0d9055626cb929b8560c0c250ecb4b.tar.gz
Merge commit '3835e52' into release-0.14 (Fix info callback support so it gets the Connection instance again)
-rw-r--r--.gitignore3
-rw-r--r--OpenSSL/SSL.py2
-rw-r--r--OpenSSL/test/test_ssl.py20
3 files changed, 16 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..867434b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+build
+dist
+*.egg-info \ No newline at end of file
diff --git a/OpenSSL/SSL.py b/OpenSSL/SSL.py
index 81ec2e2..f21ad9d 100644
--- a/OpenSSL/SSL.py
+++ b/OpenSSL/SSL.py
@@ -699,7 +699,7 @@ class Context(object):
"""
@wraps(callback)
def wrapper(ssl, where, return_code):
- callback(self, where, return_code)
+ callback(Connection._reverse_mapping[ssl], where, return_code)
self._info_callback = _ffi.callback(
"void (*)(const SSL *, int, int)", wrapper)
_lib.SSL_CTX_set_info_callback(self._context, self._info_callback)
diff --git a/OpenSSL/test/test_ssl.py b/OpenSSL/test/test_ssl.py
index e3518c5..a9b9890 100644
--- a/OpenSSL/test/test_ssl.py
+++ b/OpenSSL/test/test_ssl.py
@@ -700,15 +700,19 @@ class ContextTests(TestCase, _LoopbackMixin):
serverSSL = Connection(context, server)
serverSSL.set_accept_state()
- while not called:
- for ssl in clientSSL, serverSSL:
- try:
- ssl.do_handshake()
- except WantReadError:
- pass
+ handshake(clientSSL, serverSSL)
- # Kind of lame. Just make sure it got called somehow.
- self.assertTrue(called)
+ # The callback must always be called with a Connection instance as the
+ # first argument. It would probably be better to split this into
+ # separate tests for client and server side info callbacks so we could
+ # assert it is called with the right Connection instance. It would
+ # also be good to assert *something* about `where` and `ret`.
+ notConnections = [
+ conn for (conn, where, ret) in called
+ if not isinstance(conn, Connection)]
+ self.assertEqual(
+ [], notConnections,
+ "Some info callback arguments were not Connection instaces.")
def _load_verify_locations_test(self, *args):