コード例 #1
0
ファイル: auth_handler.py プロジェクト: thefinn93/letsencrypt
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)
コード例 #2
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)