HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/acme/__pycache__/challenges.cpython-38.pyc
U

[^8�@s�dZddlZddlZddlZddlZddlmZddlZddl	Z	ddl
Z
ddlmZe�
e�ZGdd�dej�ZGdd�dej�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�Ze
�ej�Gdd�de��ZejGdd�de��ZejGdd�de��ZejGdd�de��ZejGdd�de��ZejGdd�de��ZejGdd�de��ZejGdd�de��Z ejGdd �d e��Z!dS)!z&ACME Identifier Validation Challenges.�N)�hashes)�fieldscs(eZdZdZiZe�fdd��Z�ZS)�	ChallengezACME challenge.c
sTztt|��|�WStjk
rN}zt�|�t�|�WY�Sd}~XYnXdS�N)�superr�	from_json�joseZUnrecognizedTypeError�logger�debug�UnrecognizedChallenge)�cls�jobj�error��	__class__��1/usr/lib/python3/dist-packages/acme/challenges.pyrs

zChallenge.from_json)�__name__�
__module__�__qualname__�__doc__�TYPES�classmethodr�
__classcell__rrrrrsrc@s"eZdZdZiZdZe�e�ZdS)�ChallengeResponsezACME challenge response.Z	challengeN)	rrrrrZ
resource_typerZResource�resourcerrrrrsrcs4eZdZdZ�fdd�Zdd�Zedd��Z�ZS)ralUnrecognized challenge.

    ACME specification defines a generic framework for challenges and
    defines some standard challenges that are implemented in this
    module. However, other implementations (including peers) might
    define additional challenge types, which should be ignored if
    unrecognized.

    :ivar jobj: Original JSON decoded object.

    cs tt|���t�|d|�dS)Nr
)rr�__init__�object�__setattr__��selfr
rrrr4szUnrecognizedChallenge.__init__cCs|jSr)r
�r rrr�to_partial_json8sz%UnrecognizedChallenge.to_partial_jsoncCs||�Srr)rr
rrrr;szUnrecognizedChallenge.from_json)	rrrrrr"rrrrrrrr's
rc@s@eZdZdZdZejdejej	ej
edd�d�Zedd��Z
d	S)
�_TokenChallengez3Challenge with token.

    :ivar bytes token:

    g0@�tokenT)�sizeZminimum)�encoder�decodercCsd|jkod|jkS)z�Is `token` good?

        .. todo:: acme-spec wants "It MUST NOT contain any non-ASCII
           characters", but it should also warrant that it doesn't
           contain ".." or "/"...

        s..�/)r$r!rrr�
good_tokenOsz_TokenChallenge.good_tokenN)rrrrZ
TOKEN_SIZEr�FieldZencode_b64jose�	functools�partialZdecode_b64joser$�propertyr)rrrrr#@s��r#cs8eZdZdZe�d�ZejZ	dd�Z
�fdd�Z�ZS)�!KeyAuthorizationChallengeResponsez_Response to Challenges based on Key Authorization.

    :param unicode key_authorization:

    �keyAuthorizationcCs�|j�d�}t|�dkr*t�d|j�dS|d|�d�krXt�d|d|�d��dSt�|j|j	d���
�}|d	|kr�t�d
|d|�dSdS)a%Verify the key authorization.

        :param KeyAuthorization chall: Challenge that corresponds to
            this response.
        :param JWK account_public_key:

        :return: ``True`` iff verification of the key authorization was
            successful.
        :rtype: bool

        �.�z)Key authorization (%r) is not well formedFrr$z8Mismatching token in key authorization: %r instead of %r�Z
hash_function�z=Mismatching thumbprint in key authorization: %r instead of %rT)�key_authorization�split�lenr	r
�encoder�	b64encode�
thumbprint�thumbprint_hash_function�decode)r �chall�account_public_key�partsr9rrr�verifygs,����z(KeyAuthorizationChallengeResponse.verifycstt|���}|�dd�|S)Nr/)rr.r"�poprrrrr"�sz1KeyAuthorizationChallengeResponse.to_partial_json)
rrrrrr*r4rZSHA256r:r?r"rrrrrr.^s

 r.c@sDeZdZdZeZeZejZdd�Z	dd�Z
ejdd��Z
dd	�Zd
S)�KeyAuthorizationChallengez�Challenge based on Key Authorization.

    :param response_cls: Subclass of `KeyAuthorizationChallengeResponse`
        that will be used to generate `response`.
    :param str typ: type of the challenge
    cCs&|�d�dt�|j|jd����S)z^Generate Key Authorization.

        :param JWK account_key:
        :rtype unicode:

        r$r0r2)r7rr8r9r:r;�r �account_keyrrrr4�s
��z+KeyAuthorizationChallenge.key_authorizationcCs|j|�|�d�S)z�Generate response to the challenge.

        :param JWK account_key:

        :returns: Response (initialized `response_cls`) to the challenge.
        :rtype: KeyAuthorizationChallengeResponse

        �r4)�response_clsr4rBrrr�response�s	�z"KeyAuthorizationChallenge.responsecKs
t��dS)a�Generate validation for the challenge.

        Subclasses must implement this method, but they are likely to
        return completely different data structures, depending on what's
        necessary to complete the challenge. Interpretation of that
        return value must be known to the caller.

        :param JWK account_key:
        :returns: Challenge-specific validation.

        N��NotImplementedError�r rC�kwargsrrr�
validation�s
z$KeyAuthorizationChallenge.validationcOs|�|�|j|f|�|�fS)z�Generate response and validation.

        Convenience function that return results of `response` and
        `validation`.

        :param JWK account_key:
        :rtype: tuple

        )rFrK)r rC�argsrJrrr�response_and_validation�s
�z1KeyAuthorizationChallenge.response_and_validationN)rrrr�NotImplemented�typrEr.r:r4rF�abc�abstractmethodrKrMrrrrrA�s�
rAc@seZdZdZdZdd�ZdS)�
DNS01ResponsezACME dns-01 challenge response.zdns-01cCs|�||�}|st�d�|S)a�Simple verify.

        This method no longer checks DNS records and is a simple wrapper
        around `KeyAuthorizationChallengeResponse.verify`.

        :param challenges.DNS01 chall: Corresponding challenge.
        :param unicode domain: Domain name being verified.
        :param JWK account_public_key: Public key for the key pair
            being authorized.

        :return: ``True`` iff verification of the key authorization was
            successful.
        :rtype: bool

        �4Verification of key authorization in response failed)r?r	r
)r r<�domainr=Zverifiedrrr�
simple_verify�s
zDNS01Response.simple_verifyN)rrrrrOrUrrrrrR�srRc@s.eZdZdZeZejZdZdd�Zdd�Z	dS)�DNS01zACME dns-01 challenge.�_acme-challengecKs$t�t�|�|��d�������S)�WGenerate validation.

        :param JWK account_key:
        :rtype: unicode

        �utf-8)rr8�hashlibZsha256r4r7Zdigestr;�r rCZ
unused_kwargsrrrrK�s
��zDNS01.validationcCsd�|j|�S�zkDomain name for TXT validation record.

        :param unicode name: Domain name being validated.

        z{0}.{1}��format�LABEL�r �namerrr�validation_domain_name�szDNS01.validation_domain_nameN)
rrrrrRrErOr_rKrbrrrrrV�s
rVc@s&eZdZdZdZdZdZddd�ZdS)	�HTTP01Responsez ACME http-01 challenge response.zhttp-01�Pz

	 Nc	
Cs�|�||�st�d�dS|dk	rF||jkrFt�d|�|d�|�7}|�|�}t�d|j|�zt�	|�}Wn:tj
jk
r�}zt�d||�WY�dSd}~XYnXt�d||j
|j�|j
�|j�}|j|kr�t�d	|j|�dSd
S)a�Simple verify.

        :param challenges.SimpleHTTP chall: Corresponding challenge.
        :param unicode domain: Domain name being verified.
        :param JWK account_public_key: Public key for the key pair
            being authorized.
        :param int port: Port used in the validation.

        :returns: ``True`` iff validation with the files currently served by the
            HTTP server is successful.
        :rtype: bool

        rSFNz4Using non-standard port for http-01 verification: %sz:{0}zVerifying %s at %s...zUnable to reach %s: %szReceived %s: %s. Headers: %szEKey authorization from response (%r) doesn't match HTTP response (%r)T)r?r	r
�PORTZwarningr^�urirO�requests�get�
exceptionsZRequestExceptionr�textZheaders�rstrip�WHITESPACE_CUTSETr4)	r r<rTr=ZportrfZ
http_responserZchallenge_responserrrrUs8
�
�
�zHTTP01Response.simple_verify)N)rrrrrOrerlrUrrrrrcs
rcc@s:eZdZdZeZejZdZedd��Z	dd�Z
dd�Zd	S)
�HTTP01zACME http-01 challenge.z.well-known/acme-challengecCsd|jd|�d�S)zTPath (starting with '/') for provisioned resource.

        :rtype: string

        �/r$)�
URI_ROOT_PATHr7r!rrr�pathLszHTTP01.pathcCsd||jS)z�Create an URI to the provisioned resource.

        Forms an URI to the HTTPS server provisioned resource
        (containing :attr:`~SimpleHTTP.token`).

        :param unicode domain: Domain name being verified.
        :rtype: string

        zhttp://)rp)r rTrrrrfUs
z
HTTP01.uricKs
|�|�S)rXrDr[rrrrKaszHTTP01.validationN)rrrrrcrErOror-rprfrKrrrrrmCs
rmc@seZdZdZdZdS)�TLSALPN01ResponseaACME TLS-ALPN-01 challenge response.

    This class only allows initiating a TLS-ALPN-01 challenge returned from the
    CA. Full support for responding to TLS-ALPN-01 challenges by generating and
    serving the expected response certificate is not currently provided.
    �tls-alpn-01N)rrrrrOrrrrrqksrqc@s eZdZdZdZeZdd�ZdS)�	TLSALPN01z�ACME tls-alpn-01 challenge.

    This class simply allows parsing the TLS-ALPN-01 challenge returned from
    the CA. Full TLS-ALPN-01 support is not currently provided.

    rrcKs
t��dS)z&Generate validation for the challenge.NrGrIrrrrK�szTLSALPN01.validationN)rrrrrOrqrErKrrrrrsvsrsc@s>eZdZdZdZdZejfdd�Zdd�Z	dd	�Z
d
d�ZdS)
�DNSzACME "dns" challenge.�dnsrWcKs(tjjf|jdd��d�||d�|��S)z�Generate validation.

        :param .JWK account_key: Private account key.
        :param .JWA alg:

        :returns: This challenge wrapped in `.JWS`
        :rtype: .JWS

        T)Z	sort_keysrY)�payload�key�alg)r�JWSZsignZ
json_dumpsr7)r rCrxrJrrr�gen_validation�s
��zDNS.gen_validationc
Csd|j|d�sdSz||�|j�d��kWStjk
r^}zt�d|�WY�dSd}~XYnXdS)zwCheck validation.

        :param JWS validation:
        :param JWK account_public_key:
        :rtype: bool

        )rwFrYz&Checking validation for DNS failed: %sN)r?Z
json_loadsrvr;rZDeserializationErrorr	r
)r rKr=rrrr�check_validation�s
�zDNS.check_validationcKst|j|f|�d�S)z�Generate response.

        :param .JWK account_key: Private account key.
        :param .JWA alg:

        :rtype: DNSResponse

        )rK)�DNSResponserzrIrrr�gen_response�s
	��zDNS.gen_responsecCsd�|j|�Sr\r]r`rrrrb�szDNS.validation_domain_nameN)rrrrrOr_rZRS256rzr{r}rbrrrrrt�srtc@s.eZdZdZdZejdejjd�Z	dd�Z
dS)r|z@ACME "dns" challenge response.

    :param JWS validation:

    rurK)r'cCs|�|j|�S)z~Check validation.

        :param challenges.DNS chall:
        :param JWK account_public_key:

        :rtype: bool

        )r{rK)r r<r=rrrr{�s	zDNSResponse.check_validationN)rrrrrOrr*ryrrKr{rrrrr|�sr|)"rrPr+rZZloggingZcryptography.hazmat.primitivesrZjosepyrrgZsixZacmerZ	getLoggerrr	ZTypedJSONObjectWithFieldsrrrr#r.Z
add_metaclass�ABCMetarA�registerrRrVrcrmrqrsrtr|rrrr�<module>sB
/
@='
;