Skip to content

Commit

Permalink
hooks: cryptography: rework the OpenSSL version check
Browse files Browse the repository at this point in the history
Instead of trying to infer OpenSSL version by looking at
`CRYPTOGRAPHY_OPENSSL_300_OR_GREATER` attribute of
`cryptography.hazmat.backends.openssl.backend._lib`, use
`cryptography.hazmat.backends.openssl.backend.openssl_version_number()`
to obtain full OpenSSL version number.

Fixes compatibility with `cryptography` 43.0.0, where the
afore-mentioned attribute does not seem to be available anymore.
`openssl_version_number()`, on the other hand, seems to be
available in all versions going back to 2.8 (which is the first
version that supports python 3.8).
  • Loading branch information
rokm committed Jul 26, 2024
1 parent cdefa59 commit c6f79f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion _pyinstaller_hooks_contrib/stdhooks/hook-cryptography.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
@isolated.decorate
def _check_cryptography_openssl3():
from cryptography.hazmat.backends.openssl.backend import backend
return bool(backend._lib.CRYPTOGRAPHY_OPENSSL_300_OR_GREATER)
openssl_version = backend.openssl_version_number()
return openssl_version >= 0x30000000

uses_openssl3 = _check_cryptography_openssl3()
except Exception:
Expand Down
2 changes: 2 additions & 0 deletions news/768.update.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Rework the OpenSSL version check in ``cryptography`` hook to fix
compatibility with ``cryptography`` 43.0.0.

0 comments on commit c6f79f1

Please sign in to comment.