From 3fff0dd747a81e8ab2139d2b403db9dd0137e3ea Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 11 May 2020 18:23:36 +0200 Subject: [PATCH] lint! --- src/OpenSSL/SSL.py | 23 ++++++++++++++++------- tests/test_ssl.py | 10 +++++++--- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/OpenSSL/SSL.py b/src/OpenSSL/SSL.py index 0d10ab3d4..93ff950a9 100644 --- a/src/OpenSSL/SSL.py +++ b/src/OpenSSL/SSL.py @@ -680,7 +680,7 @@ def explode(*args, **kwargs): _requires_keylog = _make_requires( - getattr(_lib,"Cryptography_HAS_KEYLOG", None), "Key logging not available" + getattr(_lib, "Cryptography_HAS_KEYLOG", None), "Key logging not available" ) @@ -1331,20 +1331,29 @@ def wrapper(ssl, where, return_code): def set_keylog_callback(self, callback): """ Set the TLS key logging callback to *callback*. This function will be - called whenever TLS key material is generated or received, - in order to allow applications to store this keying material for debugging purposes. + called whenever TLS key material is generated or received, in order + to allow applications to store this keying material for debugging + purposes. :param callback: The Python callback to use. This should take two - arguments: a Connection object and a bytestring that contains the key material - in the format used by NSS for its SSLKEYLOGFILE debugging output. + arguments: a Connection object and a bytestring that contains + the key material in the format used by NSS for its SSLKEYLOGFILE + debugging output. :return: None """ @wraps(callback) def wrapper(ssl, line): line = _ffi.string(line) callback(Connection._reverse_mapping[ssl], line) - self._keylog_callback = _ffi.callback("void (*)(const SSL *, const char *)", wrapper) - _lib.SSL_CTX_set_keylog_callback(self._context, self._keylog_callback) + + self._keylog_callback = _ffi.callback( + "void (*)(const SSL *, const char *)", + wrapper + ) + _lib.SSL_CTX_set_keylog_callback( + self._context, + self._keylog_callback + ) def get_app_data(self): """ diff --git a/tests/test_ssl.py b/tests/test_ssl.py index d29f66df0..5886d112c 100644 --- a/tests/test_ssl.py +++ b/tests/test_ssl.py @@ -948,7 +948,7 @@ def info(conn, where, ret): @pytest.mark.skipif( not getattr(_lib, "Cryptography_HAS_KEYLOG", None), - reason="SSL_CTX_set_keylog_callback unavailable - OpenSSL version may be too old" + reason="SSL_CTX_set_keylog_callback unavailable" ) def test_set_keylog_callback(self): """ @@ -962,8 +962,12 @@ def keylog(conn, line): server_context = Context(TLSv1_METHOD) server_context.set_keylog_callback(keylog) - server_context.use_certificate(load_certificate(FILETYPE_PEM, cleartextCertificatePEM)) - server_context.use_privatekey(load_privatekey(FILETYPE_PEM, cleartextPrivateKeyPEM)) + server_context.use_certificate( + load_certificate(FILETYPE_PEM, cleartextCertificatePEM) + ) + server_context.use_privatekey( + load_privatekey(FILETYPE_PEM, cleartextPrivateKeyPEM) + ) client_context = Context(TLSv1_METHOD)