示例#1
0
def challb_to_achall(challb, key, domain):
    """Converts a ChallengeBody object to an AnnotatedChallenge.

    :param challb: ChallengeBody
    :type challb: :class:`acme.messages.ChallengeBody`

    :param key: Key
    :type key: :class:`letsencrypt.le_util.Key`

    :param str domain: Domain of the challb

    :returns: Appropriate AnnotatedChallenge
    :rtype: :class:`letsencrypt.achallenges.AnnotatedChallenge`

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

    if isinstance(chall, challenges.DVSNI):
        return achallenges.DVSNI(challb=challb, domain=domain, key=key)
    elif isinstance(chall, challenges.SimpleHTTP):
        return achallenges.SimpleHTTP(challb=challb, domain=domain, key=key)
    elif isinstance(chall, challenges.DNS):
        return achallenges.DNS(challb=challb, domain=domain)
    elif isinstance(chall, challenges.RecoveryToken):
        return achallenges.RecoveryToken(challb=challb, domain=domain)
    elif isinstance(chall, challenges.RecoveryContact):
        return achallenges.RecoveryContact(challb=challb, domain=domain)
    elif isinstance(chall, challenges.ProofOfPossession):
        return achallenges.ProofOfPossession(challb=challb, domain=domain)

    else:
        raise errors.Error("Received unsupported challenge of type: %s",
                           chall.typ)
示例#2
0
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:`letsencrypt.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)
    elif isinstance(chall, challenges.RecoveryContact):
        return achallenges.RecoveryContact(challb=challb, domain=domain)
    elif isinstance(chall, challenges.ProofOfPossession):
        return achallenges.ProofOfPossession(challb=challb, domain=domain)
    else:
        raise errors.Error("Received unsupported challenge of type: %s",
                           chall.typ)
示例#3
0
 def setUp(self):
     from letsencrypt.errors import FailedChallenges
     self.error = FailedChallenges(
         set([
             achallenges.DNS(domain="example.com",
                             challb=messages.ChallengeBody(
                                 chall=acme_util.DNS,
                                 uri=None,
                                 error=messages.Error(typ="tls",
                                                      detail="detail")))
         ]))