Use fresh authorizations in dry runs (#7442)

* acme: re-populate uri in deactivate_authorization

* Use fresh authorizations in dry runs

--dry-run now deactivates 'valid' authorizations if it encounters them
when creating a new order.

Resolves #5116.

* remove unused code

* typo in local-oldest-requirements

* better error handling

* certbot-ci: AUTHREUSE to 100 + unskip dry-run test

* improve test coverage for error cases

* restore newline to local-oldest-requirements.txt
This commit is contained in:
alexzorin
2019-11-04 21:23:25 +01:00
committed by Adrien Ferrand
parent 1c05b9bd07
commit 08d91b456b
10 changed files with 141 additions and 5 deletions
+27 -1
View File
@@ -7,8 +7,9 @@ import zope.component
from acme import challenges
from acme import messages
from acme import errors as acme_errors
# pylint: disable=unused-import, no-name-in-module
from acme.magic_typing import Dict, List
from acme.magic_typing import Dict, List, Tuple
# pylint: enable=unused-import, no-name-in-module
from certbot import achallenges
from certbot import errors
@@ -97,6 +98,31 @@ class AuthHandler(object):
return authzrs_validated
def deactivate_valid_authorizations(self, orderr):
# type: (messages.OrderResource) -> Tuple[List, List]
"""
Deactivate all `valid` authorizations in the order, so that they cannot be re-used
in subsequent orders.
:param messages.OrderResource orderr: must have authorizations filled in
:returns: tuple of list of successfully deactivated authorizations, and
list of unsuccessfully deactivated authorizations.
:rtype: tuple
"""
to_deactivate = [authzr for authzr in orderr.authorizations
if authzr.body.status == messages.STATUS_VALID]
deactivated = []
failed = []
for authzr in to_deactivate:
try:
authzr = self.acme.deactivate_authorization(authzr)
deactivated.append(authzr)
except acme_errors.Error as e:
failed.append(authzr)
logger.debug('Failed to deactivate authorization %s: %s', authzr.uri, e)
return (deactivated, failed)
def _poll_authorizations(self, authzrs, max_retries, best_effort):
"""
Poll the ACME CA server, to wait for confirmation that authorizations have their challenges