Skip to content

Commit

Permalink
Process DNS Challenges appropriately (1 challenge -> 1 domain)
Browse files Browse the repository at this point in the history
  • Loading branch information
castrapel committed Apr 25, 2019
1 parent 2bc604e commit 39584f2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lemur/plugins/lemur_acme/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ def __init__(self):
current_app.logger.error(f"Unable to fetch DNS Providers: {e}")
self.all_dns_providers = []

def find_dns_challenge(self, authorizations):
def find_dns_challenge(self, host, authorizations):
dns_challenges = []
for authz in authorizations:
if not authz.body.identifier.value == host:
continue
for combo in authz.body.challenges:
if isinstance(combo.chall, challenges.DNS01):
dns_challenges.append(combo)
Expand All @@ -72,13 +74,13 @@ def maybe_add_extension(self, host, dns_provider_options):
def start_dns_challenge(self, acme_client, account_number, host, dns_provider, order, dns_provider_options):
current_app.logger.debug("Starting DNS challenge for {0}".format(host))

dns_challenges = self.find_dns_challenge(order.authorizations)
change_ids = []

host_to_validate = self.maybe_remove_wildcard(host)
host_to_validate = self.maybe_add_extension(host_to_validate, dns_provider_options)
dns_challenges = self.find_dns_challenge(host_to_validate, order.authorizations)

for dns_challenge in self.find_dns_challenge(order.authorizations):
for dns_challenge in dns_challenges:
change_id = dns_provider.create_txt_record(
dns_challenge.validation_domain_name(host_to_validate),
dns_challenge.validation(acme_client.client.net.key),
Expand Down Expand Up @@ -140,7 +142,7 @@ def request_certificate(self, acme_client, authorizations, order):
deadline = datetime.datetime.now() + datetime.timedelta(seconds=90)

try:
orderr = acme_client.finalize_order(order, deadline)
orderr = acme_client.poll_and_finalize(order, deadline)
except AcmeError:
sentry.captureException(extra={"order_url": order.uri})
metrics.send('request_certificate_error', 'counter', 1)
Expand Down

0 comments on commit 39584f2

Please sign in to comment.