How to use the acme.challenges function in acme

To help you get started, we’ve selected a few acme examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oGGy990 / certbot-dns-inwx / certbot_inwx / inwxauth.py View on Github external
def get_chall_pref(self, domain):
        """Return list of challenge preferences.

        :param str domain: Domain for which challenge preferences are sought.
        
        :returns: List of challenge types (subclasses of
            :class:`acme.challenges.Challenge`) with the most
            preferred challenges first. If a type is not specified, it means the
            Authenticator cannot perform the challenge.
        :rtype: list
        
        """
        return [challenges.DNS01]
github certbot / certbot / letsencrypt / plugins / standalone / authenticator.py View on Github external
def get_chall_pref(self, unused_domain):  # pylint: disable=no-self-use
        """Get challenge preferences.

        IAuthenticator interface method get_chall_pref.
        Return a list of challenge types that this authenticator
        can perform for this domain.  In the case of the
        StandaloneAuthenticator, the only challenge type that can ever
        be performed is dvsni.

        :returns: A list containing only 'dvsni'.

        """
        return [challenges.DVSNI]
github certbot / certbot / certbot / certbot / _internal / auth_handler.py View on Github external
def challb_to_achall(challb, account_key, domain):
    """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`

    """
    chall = challb.chall
    logger.info("%s challenge for %s", chall.typ, domain)

    if isinstance(chall, challenges.KeyAuthorizationChallenge):
        return achallenges.KeyAuthorizationAnnotatedChallenge(
            challb=challb, domain=domain, account_key=account_key)
    elif isinstance(chall, challenges.DNS):
        return achallenges.DNS(challb=challb, domain=domain)
    raise errors.Error(
        "Received unsupported challenge of type: {0}".format(chall.typ))
github certbot / certbot / letsencrypt / proof_of_possession.py View on Github external
:returns: Response or False if the challenge cannot be completed
        :rtype: :class:`acme.challenges.ProofOfPossessionResponse`
            or False

        """
        if os.path.isfile(key_path):
            with open(key_path, 'rb') as key:
                try:
                    # Needs to be changed if JWKES doesn't have a key attribute
                    jwk = achall.alg.kty.load(key.read())
                    sig = other.Signature.from_msg(achall.nonce, jwk.key,
                                                   alg=achall.alg)
                except (IndexError, ValueError, TypeError, jose.errors.Error):
                    return False
            return challenges.ProofOfPossessionResponse(nonce=achall.nonce,
                                                        signature=sig)
        return False
github kiddouk / letslambda / letslambda.py View on Github external
    dns_challenges = filter(lambda x: isinstance(x.chall, challenges.DNS01), authorization_resource.body.challenges)
    return list(dns_challenges)[0]
github certbot / certbot / letsencrypt / continuity_auth.py View on Github external
def get_chall_pref(self, unused_domain):  # pylint: disable=no-self-use
        """Return list of challenge preferences."""
        return [challenges.ProofOfPossession]
github gboudreau / certbot-heroku / certbot_heroku / configurator.py View on Github external
def get_chall_pref(self, domain):  # pragma: no cover
        # pylint: disable=missing-docstring,no-self-use,unused-argument
        return [challenges.HTTP01]
github certbot / certbot / certbot / cli.py View on Github external
"""Translate and validate preferred challenges.

    :param pref_challs: list of preferred challenge types
    :type pref_challs: `list` of `str`

    :returns: validated list of preferred challenge types
    :rtype: `list` of `str`

    :raises errors.Error: if pref_challs is invalid

    """
    aliases = {"dns": "dns-01", "http": "http-01", "tls-sni": "tls-sni-01"}
    challs = [c.strip() for c in pref_challs]
    challs = [aliases.get(c, c) for c in challs]
    unrecognized = ", ".join(name for name in challs
                             if name not in challenges.Challenge.TYPES)
    if unrecognized:
        raise errors.Error(
            "Unrecognized challenges: {0}".format(unrecognized))
    return challs
github certbot / certbot / certbot / plugins / route53.py View on Github external
def supported_challenges(self):
        """Challenges supported by this plugin."""
        return [challenges.Challenge.TYPES[challenges.DNS01.typ]]
github EFForg / starttls-everywhere / certbot / acme / acme / messages.py View on Github external
def fields_from_json(cls, jobj):
        jobj_fields = super(ChallengeBody, cls).fields_from_json(jobj)
        jobj_fields['chall'] = challenges.Challenge.from_json(jobj)
        return jobj_fields