acme_challenge_cert_helper: adjust private key check (#1007)

* Adjust private key check.

* Fix sorting.
This commit is contained in:
Felix Fontein
2026-04-25 13:32:31 +02:00
committed by GitHub
parent f94dc9227a
commit 070891b873
2 changed files with 11 additions and 7 deletions

View File

@@ -0,0 +1,2 @@
bugfixes:
- "acme_challenge_cert_helper - adjust private key check for new private key types in cryptography 47.0.0 (https://github.com/ansible-collections/community.crypto/pull/1007)."

View File

@@ -175,13 +175,13 @@ from ansible_collections.community.crypto.plugins.module_utils._time import (
try:
import cryptography
import cryptography.hazmat.backends
import cryptography.hazmat.primitives.asymmetric.dh
import cryptography.hazmat.primitives.asymmetric.dsa
import cryptography.hazmat.primitives.asymmetric.ec
import cryptography.hazmat.primitives.asymmetric.ed448
import cryptography.hazmat.primitives.asymmetric.ed25519
import cryptography.hazmat.primitives.asymmetric.padding
import cryptography.hazmat.primitives.asymmetric.rsa
import cryptography.hazmat.primitives.asymmetric.utils
import cryptography.hazmat.primitives.asymmetric.x448
import cryptography.hazmat.primitives.asymmetric.x25519
import cryptography.hazmat.primitives.hashes
import cryptography.hazmat.primitives.serialization
import cryptography.x509
@@ -241,12 +241,14 @@ def main() -> t.NoReturn:
)
except Exception as e:
raise ModuleFailException(f"Error while loading private key: {e}") from e
if isinstance(
if not isinstance(
private_key,
(
cryptography.hazmat.primitives.asymmetric.dh.DHPrivateKey,
cryptography.hazmat.primitives.asymmetric.x25519.X25519PrivateKey,
cryptography.hazmat.primitives.asymmetric.x448.X448PrivateKey,
cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PrivateKey,
cryptography.hazmat.primitives.asymmetric.ed448.Ed448PrivateKey,
cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey,
cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey,
cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey,
),
):
raise ModuleFailException(