diff options
-rw-r--r-- | CHANGELOG.rst | 3 | ||||
-rw-r--r-- | INSTALL.rst | 3 | ||||
-rw-r--r-- | src/OpenSSL/debug.py | 42 | ||||
-rw-r--r-- | tests/test_debug.py | 10 | ||||
-rw-r--r-- | tests/test_util.py | 6 | ||||
-rw-r--r-- | tox.ini | 1 |
6 files changed, 60 insertions, 5 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1c7a69d..ae9e359 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -24,7 +24,8 @@ Deprecations: Changes: ^^^^^^^^ -*none* +- Added ``OpenSSL.debug`` that allows to get an overview of used library versions (including linked OpenSSL) and other useful runtime information using ``python -m OpenSSL.debug``. + `#620 <https://github.com/pyca/pyopenssl/pull/620>`_ ---- diff --git a/INSTALL.rst b/INSTALL.rst index d6c9410..71fe1ed 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -29,12 +29,13 @@ Currently that means: - 1.0.2 - 1.1.0 - If you need support for older releases, the following pinned versions will work: - **OpenSSL 0.9.8**: ``'pyOpenSSL<17.0' 'cryptography<1.4'`` - **OpenSSL 1.0.0**: ``'pyOpenSSL<17.1' 'cryptography<1.7'`` +You can always find out the versions of pyOpenSSL, cryptography, and the linked OpenSSL by running ``python -m OpenSSL.debug``. + Documentation ------------- diff --git a/src/OpenSSL/debug.py b/src/OpenSSL/debug.py new file mode 100644 index 0000000..0d37bf5 --- /dev/null +++ b/src/OpenSSL/debug.py @@ -0,0 +1,42 @@ +from __future__ import print_function + +import ssl +import sys + +import OpenSSL.SSL +import cffi +import cryptography + +from . import version + + +_env_info = u"""\ +pyOpenSSL: {pyopenssl} +cryptography: {cryptography} +cffi: {cffi} +cryptography's compiled against OpenSSL: {crypto_openssl_compile} +cryptography's linked OpenSSL: {crypto_openssl_link} +Pythons's OpenSSL: {python_openssl} +Python executable: {python} +Python version: {python_version} +Platform: {platform} +sys.path: {sys_path}""".format( + pyopenssl=version.__version__, + crypto_openssl_compile=OpenSSL._util.ffi.string( + OpenSSL._util.lib.OPENSSL_VERSION_TEXT, + ).decode("ascii"), + crypto_openssl_link=OpenSSL.SSL.SSLeay_version( + OpenSSL.SSL.SSLEAY_VERSION + ).decode("ascii"), + python_openssl=getattr(ssl, "OPENSSL_VERSION", "n/a"), + cryptography=cryptography.__version__, + cffi=cffi.__version__, + python=sys.executable, + python_version=sys.version, + platform=sys.platform, + sys_path=sys.path, +) + + +if __name__ == "__main__": + print(_env_info) diff --git a/tests/test_debug.py b/tests/test_debug.py new file mode 100644 index 0000000..2d62a3a --- /dev/null +++ b/tests/test_debug.py @@ -0,0 +1,10 @@ +from OpenSSL.debug import _env_info +from OpenSSL import version + + +def test_debug_info(): + """ + Debug info contains correct data. + """ + # Just check a sample we control. + assert version.__version__ in _env_info diff --git a/tests/test_util.py b/tests/test_util.py index 78c97b5..91847e0 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,7 +1,7 @@ -from OpenSSL._util import exception_from_error_queue, lib - import pytest +from OpenSSL._util import exception_from_error_queue, lib + class TestErrors(object): """ @@ -9,7 +9,7 @@ class TestErrors(object): """ def test_exception_from_error_queue_nonexistent_reason(self): """ - :py:func:`exception_from_error_queue` raises ``ValueError`` when it + :func:`exception_from_error_queue` raises ``ValueError`` when it encounters an OpenSSL error code which does not have a reason string. """ lib.ERR_put_error(lib.ERR_LIB_EVP, 0, 1112, b"", 10) @@ -17,6 +17,7 @@ setenv = PIP_NO_BINARY=cryptography commands = openssl version + coverage run --parallel -m OpenSSL.debug coverage run --parallel -m pytest -v {posargs} [testenv:py27-twistedMaster] |