[SOLVED] Nitropy LibraryNotFoundError('Error detecting the version of libcrypto')

I just installed nitropy on my Debian 12 (Bookworm) as explained in documentation (pipx) to update my Nitrokey 3A NFC. The installation went well without any issue.
When I try to launch nitropy, it raises an error:

$ nitropy nk3 list
Command line tool to interact with Nitrokey devices 0.4.41
:: 'Nitrokey 3' keys
Critical error:
An unhandled exception occurred
	Exception encountered: LibraryNotFoundError('Error detecting the version of libcrypto')

I can not attach them :unamused:, so here are the beginning and the end of the logs:

 894        INFO pynitrokey.cli Timestamp: 2023-11-21 20:28:59.527078
894        INFO pynitrokey.cli OS: uname_result(system='Linux', node='glaurung', rel
ease='6.1.0-13-amd64', version='#1 SMP PREEMPT_DYNAMIC Debian 6.1.55-1 (2023-09-29)'
, machine='x86_64')
894        INFO pynitrokey.cli Python version: 3.11.2
894        INFO pynitrokey.cli Cli arguments: ['nk3', 'list']
896        INFO pynitrokey.cli pynitrokey version: 0.4.41
897        INFO pynitrokey.cli cryptography version: 41.0.5
897        INFO pynitrokey.cli ecdsa version: 0.18.0
898        INFO pynitrokey.cli fido2 version: 1.1.2
898        INFO pynitrokey.cli pyusb version: 1.2.1
899        INFO pynitrokey.cli spsdk version: 1.11.0
899       DEBUG       root print: :: 'Nitrokey 3' keys
1106     WARNING pynitrokey.cli An unhandled exception occurred
Traceback (most recent call last):
  File "/home/olivier/.local/pipx/venvs/pynitrokey/lib/python3.11/site-packages/pyni
trokey/cli/__init__.py", line 130, in main
  File "/home/olivier/.local/pipx/venvs/pynitrokey/lib/python3.11/site-packages/clic
k/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/olivier/.local/pipx/venvs/pynitrokey/lib/python3.11/site-packages/clic
k/core.py", line 1055, in main
    rv = self.invoke(ctx)
    from ._openssl.util import rand_bytes
  File "/home/olivier/.local/pipx/venvs/pynitrokey/lib/python3.11/site-packages/oscr
ypto/_openssl/util.py", line 6, in <module>
    from ._libcrypto import libcrypto, libcrypto_version_info, handle_openssl_error
  File "/home/olivier/.local/pipx/venvs/pynitrokey/lib/python3.11/site-packages/oscr
ypto/_openssl/_libcrypto.py", line 9, in <module>
    from ._libcrypto_cffi import (
  File "/home/olivier/.local/pipx/venvs/pynitrokey/lib/python3.11/site-packages/oscr
ypto/_openssl/_libcrypto_cffi.py", line 44, in <module>
    raise LibraryNotFoundError('Error detecting the version of libcrypto')
oscrypto.errors.LibraryNotFoundError: Error detecting the version of libcrypto

Thank you for the help. I do not know where to investigate …

hey @olibois

yes, this is a bug in a transient dependency, see this Github issue: pynitrokey is not working with openssl 3.0.10: Error detecting the version of libcrypto · Issue #431 · Nitrokey/pynitrokey · GitHub
A workaround and more information why we cannot fix this currently (directly) is also listed there.

A workaround can also be found here.

Thank you @nku & @daringer !!
I change the regular expression in oscrypto/_openssl/_libcrypto_cffi.py from
version_match = re.search('\\b(\\d\\.\\d\\.\\d[a-z]*)\\b', version_string)
version_match = re.search('\\b(\\d+\\.\\d+\\.\\d+[a-z]*)\\b', version_string)
and it works fine now :sunglasses: