From 3ee18d2f167226dd2fc16959eb0b062955123967 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 26 Apr 2022 20:24:35 +0200 Subject: [PATCH] Prevent crash if PyOpenSSL cannot be imported because of an AttributeError. --- plugins/module_utils/crypto/support.py | 2 +- plugins/modules/openssl_pkcs12.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/module_utils/crypto/support.py b/plugins/module_utils/crypto/support.py index 646199851..1577abc82 100644 --- a/plugins/module_utils/crypto/support.py +++ b/plugins/module_utils/crypto/support.py @@ -32,7 +32,7 @@ try: from OpenSSL import crypto HAS_PYOPENSSL = True -except ImportError: +except (ImportError, AttributeError): # Error handled in the calling module. HAS_PYOPENSSL = False diff --git a/plugins/modules/openssl_pkcs12.py b/plugins/modules/openssl_pkcs12.py index 5c91d6e84..2702914e6 100644 --- a/plugins/modules/openssl_pkcs12.py +++ b/plugins/modules/openssl_pkcs12.py @@ -276,7 +276,7 @@ import OpenSSL from OpenSSL import crypto PYOPENSSL_VERSION = LooseVersion(OpenSSL.__version__) -except ImportError: +except (ImportError, AttributeError): PYOPENSSL_IMP_ERR = traceback.format_exc() PYOPENSSL_FOUND = False else: