Skip to content

Commit

Permalink
Prevent crash if PyOpenSSL cannot be imported because of an Attribute…
Browse files Browse the repository at this point in the history
…Error.
  • Loading branch information
felixfontein committed Apr 26, 2022
1 parent dbbcc9f commit 4e516fb
Show file tree
Hide file tree
Showing 17 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion plugins/module_utils/crypto/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import OpenSSL # noqa
from OpenSSL import crypto # noqa
HAS_PYOPENSSL = True
except ImportError:
except (ImportError, AttributeError):
# Error handled in the calling module.
HAS_PYOPENSSL = False

Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/crypto/module_backends/certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
try:
import OpenSSL
from OpenSSL import crypto
except ImportError:
except (ImportError, AttributeError):
pass

try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
# OpenSSL 1.0.x or older
OPENSSL_MUST_STAPLE_NAME = b"1.3.6.1.5.5.7.1.24"
OPENSSL_MUST_STAPLE_VALUE = b"DER:30:03:02:01:05"
except ImportError:
except (ImportError, AttributeError):
PYOPENSSL_IMP_ERR = traceback.format_exc()
PYOPENSSL_FOUND = False
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

try:
from OpenSSL import crypto
except ImportError:
except (ImportError, AttributeError):
pass

try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

try:
from OpenSSL import crypto
except ImportError:
except (ImportError, AttributeError):
pass

try:
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/crypto/module_backends/csr.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,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:
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/crypto/module_backends/csr_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
# OpenSSL 1.0.x or older
OPENSSL_MUST_STAPLE_NAME = b"1.3.6.1.5.5.7.1.24"
OPENSSL_MUST_STAPLE_VALUE = b"DER:30:03:02:01:05"
except ImportError:
except (ImportError, AttributeError):
PYOPENSSL_IMP_ERR = traceback.format_exc()
PYOPENSSL_FOUND = False
else:
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/crypto/module_backends/privatekey.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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:
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/crypto/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/get_certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,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:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/openssl_pkcs12.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/openssl_publickey.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,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:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/openssl_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,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:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/openssl_signature_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,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:
Expand Down

0 comments on commit 4e516fb

Please sign in to comment.