Coverage for certbot/auth_handler.py : 99%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
"""ACME AuthHandler."""
# pylint: disable=unused-import, no-name-in-module # pylint: enable=unused-import, no-name-in-module
"""Stores an authorization resource and its active annotated challenges."""
"""ACME Authorization Handler for a client.
:ivar auth: Authenticator capable of solving :class:`~acme.challenges.Challenge` types :type auth: :class:`certbot.interfaces.IAuthenticator`
:ivar acme.client.BackwardsCompatibleClientV2 acme_client: ACME client API.
:ivar account: Client's Account :type account: :class:`certbot.account.Account`
:ivar list pref_challs: sorted user specified preferred challenges type strings with the most preferred challenge listed first
"""
"""Retrieve all authorizations for challenges.
:param acme.messages.OrderResource orderr: must have authorizations filled in :param bool best_effort: Whether or not all authorizations are required (this is useful in renewal)
:returns: List of authorization resources :rtype: list
:raises .AuthorizationError: If unable to retrieve all authorizations
""" for authzr in orderr.authorizations]
# While there are still challenges remaining... 'Pass "-v" for more info about challenges.', pause=True)
# Send all Responses - this modifies achalls
# Just make sure all decisions are complete.
# Only return valid authorizations if aauthzr.authzr.body.status == messages.STATUS_VALID]
"Challenges failed for all domains")
""" Retrieve necessary and pending challenges to satisfy server. NB: Necessary and already validated challenges are not retrieved, as they can be reused for a certificate issuance. """ if aauthzr.authzr.body.status != messages.STATUS_VALID] else:
aauthzr_challenges, self._get_chall_pref(aauthzr.authzr.body.identifier.value), combinations)
aauthzr.authzr, path)
"""Do we have any challenges to perform?"""
"""Get Responses for challenges from authenticators."""
"""Return all active challenges."""
"""Send/Receive confirmation of all challenges.
.. note:: This method also cleans up the auth_handler state.
""" # TODO: chall_update is a dirty hack to get around acme-spec #105 # type: Dict[int, List[achallenges.KeyAuthorizationAnnotatedChallenge]]
# Check for updated status...
"""Send responses and make sure errors are handled.
:param aauthzrs: authorizations and the selected annotated challenges to try and perform :type aauthzrs: `list` of `AnnotatedAuthzr` :param resps: challenge responses from the authenticator where each response at index i corresponds to the annotated challenge at index i in the list returned by :func:`_get_all_achalls` :type resps: `collections.abc.Iterable` of :class:`~acme.challenges.ChallengeResponse` or `False` or `None` :param dict chall_update: parameter that is updated to hold aauthzr index to list of outstanding solved annotated challenges
""" # This line needs to be outside of the if block below to # ensure failed challenges are cleaned up correctly
# Don't send challenges for None and False authenticator responses # TODO: answer_challenge returns challr, with URI, # that can be used in _find_updated_challr # comparisons...
best_effort, min_sleep=3, max_rounds=30): """Wait for all challenge results to be determined."""
# TODO: Use retry-after... aauthzrs, index, chall_update[index])
# We failed some challenges... damage control else: "Challenge failed for domain %s", aauthzrs[index].authzr.body.identifier.value) else: updated for _, updated in failed_achalls)
"""Returns tuple of ('completed', 'failed')."""
# Note: if the whole authorization is invalid, the individual failed # challenges will be determined here... updated_authzr, achall))
# This does nothing for challenges that have yet to be decided yet.
"""Find updated challenge body within Authorization Resource.
.. warning:: This assumes only one instance of type of challenge in each challenge resource.
:param .AuthorizationResource authzr: Authorization Resource :param .AnnotatedChallenge achall: Annotated challenge for which to get status
""" "Target challenge not found in authorization resource")
"""Return list of challenge preferences.
:param str domain: domain for which you are requesting preferences
""" # Make sure to make a copy... "None of the preferred challenges " "are supported by the selected plugin")
"""Cleanup challenges.
:param aauthzrs: authorizations and their selected annotated challenges :type aauthzrs: `list` of `AnnotatedAuthzr` :param achalls: annotated challenges to cleanup :type achalls: `list` of :class:`certbot.achallenges.AnnotatedChallenge`
"""
"""Verifies that all authorizations have been decided.
:param aauthzrs: authorizations and their selected annotated challenges :type aauthzrs: `list` of `AnnotatedAuthzr`
:returns: Whether all authzr are complete :rtype: bool
""" authzr.body.status != messages.STATUS_INVALID):
"""Construct Namedtuple Challenges
:param messages.AuthorizationResource authzr: authorization
:param list path: List of indices from `challenges`.
:returns: achalls, list of challenge type :class:`certbot.achallenges.Indexed` :rtype: list
:raises .errors.Error: if challenge type is not recognized
"""
challb, self.account.key, authzr.body.identifier.value))
"""Converts a ChallengeBody object to an AnnotatedChallenge.
:param .ChallengeBody challb: ChallengeBody :param .JWK account_key: Authorized Account Key :param str domain: Domain of the challb
:returns: Appropriate AnnotatedChallenge :rtype: :class:`certbot.achallenges.AnnotatedChallenge`
"""
challb=challb, domain=domain, account_key=account_key) return achallenges.DNS(challb=challb, domain=domain) else: "Received unsupported challenge of type: %s", chall.typ)
"""Generate a plan to get authority over the identity.
.. todo:: This can be possibly be rewritten to use resolved_combinations.
:param tuple challbs: A tuple of challenges (:class:`acme.messages.Challenge`) from :class:`acme.messages.AuthorizationResource` to be fulfilled by the client in order to prove possession of the identifier.
:param list preferences: List of challenge preferences for domain (:class:`acme.challenges.Challenge` subclasses)
:param tuple combinations: A collection of sets of challenges from :class:`acme.messages.Challenge`, each of which would be sufficient to prove possession of the identifier.
:returns: tuple of indices from ``challenges``. :rtype: tuple
:raises certbot.errors.AuthorizationError: If a path cannot be created that satisfies the CA given the preferences and combinations.
""" else:
"""Find challenge path with server hints.
Can be called if combinations is included. Function uses a simple ranking system to choose the combo with the lowest cost.
"""
# max_cost is now equal to sum(indices) + 1
# Set above completing all of the available challenges
challenge_index].chall.__class__, max_cost)
"""Find challenge path without server hints.
Should be called if the combinations hint is not included by the server. This function either returns a path containing all challenges provided by the CA or raises an exception.
""" # supported is set to True if the challenge type is supported if isinstance(challb.chall, pref_c)), False) else:
"""Logs and raises an error that no satisfiable chall path exists.
:param challbs: challenges from the authorization that can't be satisfied
""" "any combination of challenges that will satisfy the CA.") " You may need to use an authenticator " "plugin that can do challenges over DNS.")
"To fix these errors, please make sure that your domain name was entered " "correctly and the DNS A/AAAA record(s) for that domain contain(s) the " "right IP address.")
"connection": _ERROR_HELP_COMMON + " Additionally, please check that your computer " "has a publicly routable IP address and that no firewalls are preventing " "the server from communicating with the client. If you're using the " "webroot plugin, you should also verify that you are serving files " "from the webroot path you provided.", "dnssec": _ERROR_HELP_COMMON + " Additionally, if you have DNSSEC enabled for " "your domain, please ensure that the signature is valid.", "malformed": "To fix these errors, please make sure that you did not provide any " "invalid information to the client, and try running Certbot " "again.", "serverInternal": "Unfortunately, an error on the ACME server prevented you from completing " "authorization. Please try again later.", "tls": _ERROR_HELP_COMMON + " Additionally, please check that you have an " "up-to-date TLS configuration that allows the server to communicate " "with the Certbot client.", "unauthorized": _ERROR_HELP_COMMON, "unknownHost": _ERROR_HELP_COMMON, }
"""Notifies the user about failed challenges.
:param set failed_achalls: A set of failed :class:`certbot.achallenges.AnnotatedChallenge`.
""" # type: DefaultDict[str, List[achallenges.KeyAuthorizationAnnotatedChallenge]] _generate_failed_chall_msg(achalls), reporter.MEDIUM_PRIORITY)
"""Creates a user friendly error message about failed challenges.
:param list failed_achalls: A list of failed :class:`certbot.achallenges.AnnotatedChallenge` with the same error type.
:returns: A formatted error message for the client. :rtype: str
"""
achall.domain, typ, achall.error.detail))
|