From 502818be4ce1255da64fd8a7201b474c26f51e16 Mon Sep 17 00:00:00 2001 From: nom3ad <19239479+nom3ad@users.noreply.github.com> Date: Sun, 11 Oct 2020 03:02:42 +0530 Subject: [PATCH] Fixes acm:describe_certificate for imported certificates having no SAN extension (#3370) * Fix(test_acm): describe_certificate testcase does't execute * handle acm certificates lacking extensions Co-authored-by: nom3ad --- moto/acm/models.py | 9 ++++++--- tests/test_acm/test_acm.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/moto/acm/models.py b/moto/acm/models.py index 3df54198..0608400f 100644 --- a/moto/acm/models.py +++ b/moto/acm/models.py @@ -293,9 +293,12 @@ class CertBundle(BaseModel): key_algo = "EC_prime256v1" # Look for SANs - san_obj = self._cert.extensions.get_extension_for_oid( - cryptography.x509.OID_SUBJECT_ALTERNATIVE_NAME - ) + try: + san_obj = self._cert.extensions.get_extension_for_oid( + cryptography.x509.OID_SUBJECT_ALTERNATIVE_NAME + ) + except cryptography.x509.ExtensionNotFound: + san_obj = None sans = [] if san_obj is not None: sans = [item.value for item in san_obj.value] diff --git a/tests/test_acm/test_acm.py b/tests/test_acm/test_acm.py index b38cd184..017d166d 100644 --- a/tests/test_acm/test_acm.py +++ b/tests/test_acm/test_acm.py @@ -140,7 +140,7 @@ def test_describe_certificate(): @mock_acm -def test_describe_certificate(): +def test_describe_certificate_with_bad_arn(): client = boto3.client("acm", region_name="eu-central-1") try: