lookup lowercase domain names when verifying authorizations to preven… (#803)

* lookup lowercase domain names when verifying authorizations to prevent failure when CSR has mixed-case names

Signed-off-by: Lyas Spiehler <lspiehler@gmail.com>

* remove .lower() method

* make authorizations keys lowercase

Signed-off-by: Lyas Spiehler <lspiehler@gmail.com>

* use lowercase keys for authorizations dict

Signed-off-by: Lyas Spiehler <lspiehler@gmail.com>

* use new normalize_combined_identifier function to normalize identifiers

* include two blank lines after functions to pass tests

* Update plugins/module_utils/acme/challenges.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* add changelog fragment

Signed-off-by: Lyas Spiehler <lspiehler@gmail.com>

* Update changelogs/fragments/803-fix-authorization-failure-with-mixed-case-sans.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Signed-off-by: Lyas Spiehler <lspiehler@gmail.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Lyas Spiehler
2024-10-15 10:48:47 -07:00
committed by GitHub
parent 30a16c8f60
commit a39b3bc882
4 changed files with 17 additions and 6 deletions

View File

@@ -47,6 +47,13 @@ def combine_identifier(identifier_type, identifier):
return '{type}:{identifier}'.format(type=identifier_type, identifier=identifier)
def normalize_combined_identifier(identifier):
identifier_type, identifier = split_identifier(identifier)
# Normalize DNS names and IPs
identifier = identifier.lower()
return combine_identifier(identifier_type, identifier)
def split_identifier(identifier):
parts = identifier.split(':', 1)
if len(parts) != 2:

View File

@@ -21,6 +21,7 @@ from ansible_collections.community.crypto.plugins.module_utils.acme.errors impor
from ansible_collections.community.crypto.plugins.module_utils.acme.challenges import (
Authorization,
normalize_combined_identifier,
)
@@ -93,7 +94,7 @@ class Order(object):
def load_authorizations(self, client):
for auth_uri in self.authorization_uris:
authz = Authorization.from_url(client, auth_uri)
self.authorizations[authz.combined_identifier] = authz
self.authorizations[normalize_combined_identifier(authz.combined_identifier)] = authz
def wait_for_finalization(self, client):
while True: