Skip to content

Commit

Permalink
case of no SANs and common name not a valid domain
Browse files Browse the repository at this point in the history
  • Loading branch information
paulschwarzenberger committed Feb 6, 2024
1 parent 2825583 commit 7537f35
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/terraform-aws-ca-lambda/utils/certs/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@ def crypto_ca_key_info(public_key, kms_key_id, common_name):


def crypto_cert_request_info(csr_cert, common_name, lifetime, sans):
# no SANs and common name is not a valid domain
if (sans is None or sans == []) and not domain_validator(common_name):
sans = []

# no SANs and common name is a valid domain
if (sans is None or sans == []) and domain_validator(common_name):
sans = [common_name]

# remove invalid SANs
sans = [s for s in sans if domain_validator(s)]

# convert to x509 cryptography format
x509_sans = []
for san in sans:
x509_sans.append(x509.DNSName(san))
Expand Down

0 comments on commit 7537f35

Please sign in to comment.