From e2ecd14d86297c6579d4578897981c2c960d6295 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Wed, 28 Dec 2022 20:53:02 +0100 Subject: [PATCH] Fix crash when public key cannot be parsed. (#551) (#552) (cherry picked from commit 5d24d04adf2e5e22bdcc0832a43cfb29e04836c0) Co-authored-by: Felix Fontein --- changelogs/fragments/551-publickey-info.yml | 2 ++ plugins/module_utils/crypto/module_backends/publickey_info.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/551-publickey-info.yml diff --git a/changelogs/fragments/551-publickey-info.yml b/changelogs/fragments/551-publickey-info.yml new file mode 100644 index 00000000..f235002b --- /dev/null +++ b/changelogs/fragments/551-publickey-info.yml @@ -0,0 +1,2 @@ +bugfixes: + - "openssl_publickey_info - do not crash with internal error when public key cannot be parsed (https://github.com/ansible-collections/community.crypto/pull/551)." diff --git a/plugins/module_utils/crypto/module_backends/publickey_info.py b/plugins/module_utils/crypto/module_backends/publickey_info.py index 2e071354..452b4c2d 100644 --- a/plugins/module_utils/crypto/module_backends/publickey_info.py +++ b/plugins/module_utils/crypto/module_backends/publickey_info.py @@ -215,7 +215,7 @@ class PublicKeyInfoRetrieval(object): try: self.key = load_publickey(content=self.content, backend=self.backend) except OpenSSLObjectError as e: - raise PublicKeyParseError(to_native(e)) + raise PublicKeyParseError(to_native(e), {}) pk = self._get_public_key(binary=True) result['fingerprints'] = get_fingerprint_of_bytes(