Fix EC detection. (#981)

This commit is contained in:
Felix Fontein
2026-02-11 21:44:24 +01:00
committed by GitHub
parent b5a9a41913
commit 911ed33c2e
3 changed files with 5 additions and 3 deletions

View File

@@ -0,0 +1,2 @@
bugfixes:
- "crypto_info, openssl_privatekey, openssl_privatekey_pipe - fix detection of EC support for cryptography 46.0.5+ (https://github.com/ansible-collections/community.crypto/pull/981)."

View File

@@ -98,7 +98,7 @@ class _Curve:
) -> type[cryptography.hazmat.primitives.asymmetric.ec.EllipticCurve]:
ecclass: (
type[cryptography.hazmat.primitives.asymmetric.ec.EllipticCurve] | None
) = cryptography.hazmat.primitives.asymmetric.ec.__dict__.get(self.ectype)
) = getattr(cryptography.hazmat.primitives.asymmetric.ec, self.ectype, None)
if ecclass is None:
module.fail_json(
msg=f"Your cryptography version does not support {self.ectype}"

View File

@@ -350,8 +350,8 @@ def add_crypto_information(module: AnsibleModule) -> dict[str, t.Any]:
pass
else:
for curve_name, constructor_name in CURVES:
ecclass = ec.__dict__.get(constructor_name)
if ecclass:
ecclass = getattr(ec, constructor_name, None)
if ecclass is not None:
try:
ec.generate_private_key(curve=ecclass())
curves.append(curve_name)