Skip to content

Commit

Permalink
Work around broken cryptography in Fedora 41.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Jan 8, 2025
1 parent 9462263 commit 5d65c34
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changelogs/fragments/834-crypto_info-fedora-41.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bugfixes:
- "crypto_info - when running the module on Fedora 41 with ``cryptography`` installed from the package repository,
the module crashed apparently due to some elliptic curves being removed from libssl against which cryptography
is running, which cryptography did not expect
(https://github.com/ansible-collections/community.crypto/pull/834)."
13 changes: 13 additions & 0 deletions plugins/modules/crypto_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,16 @@
try:
import cryptography
from cryptography.exceptions import UnsupportedAlgorithm

try:
# While UnsupportedAlgorithm got added in cryptography 0.1, InternalError
# only got added in 0.2, so let's guard the import
from cryptography.exceptions import InternalError as CryptographyInternalError
except ImportError:
CryptographyInternalError = Exception
except ImportError:
UnsupportedAlgorithm = Exception
CryptographyInternalError = Exception
CRYPTOGRAPHY_VERSION = None
CRYPTOGRAPHY_IMP_ERR = traceback.format_exc()
else:
Expand Down Expand Up @@ -274,6 +282,11 @@ def add_crypto_information(module):
curves.append(curve_name)
except UnsupportedAlgorithm:
pass
except CryptographyInternalError: # pylint: disable=duplicate-except,bad-except-order
# On Fedora 41, some curves result in InternalError. This is probably because
# Fedora's cryptography is linked against the system libssl, which has the
# curves removed.
pass

info = {
'version': CRYPTOGRAPHY_VERSION,
Expand Down

0 comments on commit 5d65c34

Please sign in to comment.