403Webshell
Server IP : 3.96.16.70  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux ip-172-31-26-103.ca-central-1.compute.internal 6.1.163-186.299.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Feb 24 16:35:42 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3.9/site-packages/acme/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.9/site-packages/acme/__pycache__/challenges.cpython-39.opt-1.pyc
a

�]e�W�@s dZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZddlmZddlm
Z
dd	lmZdd
lmZddlmZddlmZddlZdd
lmZddlmZddlZddlmZddlmZe�e�Zeddd�ZGdd�dej �Z!Gdd�dej �Z"Gdd�de!�Z#Gdd�de!�Z$Gdd�de"�Z%Gdd�de$ej&d�Z'e"j(Gd d!�d!e%��Z)e!j(Gd"d#�d#e'��Z*e"j(Gd$d%�d%e%��Z+e!j(Gd&d'�d'e'��Z,e"j(Gd(d)�d)e%��Z-e!j(Gd*d+�d+e'��Z.e!j(Gd,d-�d-e$��Z/e"j(Gd.d/�d/e"��Z0dS)0z&ACME Identifier Validation Challenges.�N)�Any)�cast)�Dict)�Mapping)�Optional)�Tuple)�Type)�TypeVar)�Union)�hashes)�crypto)�SSL)�crypto_util)�errors�GenericChallenge�	Challenge)�boundcs\eZdZUdZiZeeedfed<e	ee
eeefe
e
dfd��fdd��Z�ZS)rzACME challenge.�TYPES�UnrecognizedChallenge)�cls�jobj�returnc
sTzttt��|��WStjyN}z t�|�t�|�WYd}~Sd}~00dS�N)	rr�super�	from_json�joseZUnrecognizedTypeError�logger�debugr)rr�error��	__class__��3/usr/lib/python3.9/site-packages/acme/challenges.pyr%s

zChallenge.from_json)�__name__�
__module__�__qualname__�__doc__rr�strr�__annotations__�classmethodrrrr
r�
__classcell__r!r!rr"r s
�csHeZdZUdZiZeeedfed<eee	fd��fdd�Z
�ZS)�ChallengeResponsezACME challenge response.r�rcst���}|�|jd�|Sr)r�to_partial_json�popZtype_field_name��selfrrr!r"r-4s
z!ChallengeResponse.to_partial_json)r#r$r%r&rrr'rr(rr-r*r!r!rr"r+/s
r+csteZdZUdZeeefed<eeefdd��fdd�Z	eeefd�dd	�Z
eeeefdd�d
d��Z�Z
S)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.

    rN)rrcst���t�|d|�dS)Nr)r�__init__�object�__setattr__r/rr!r"r1Js
zUnrecognizedChallenge.__init__r,cCs|jSr)r�r0r!r!r"r-Nsz%UnrecognizedChallenge.to_partial_jsoncCs||�Srr!)rrr!r!r"rQszUnrecognizedChallenge.from_json)r#r$r%r&rr'rr(rr1r-r)rr*r!r!rr"r<s
rc@sPeZdZUdZdZejdejej	ej
edd�d�Zee
d<eed�dd	��Zd
S)�_TokenChallengez3Challenge with token.

    :ivar bytes token:

    g0@�tokenT)�sizeZminimum)�encoder�decoderr,cCsd|jvod|jvS)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..�/)r6r4r!r!r"�
good_tokenesz_TokenChallenge.good_tokenN)r#r$r%r&Z
TOKEN_SIZEr�fieldZencode_b64jose�	functools�partialZdecode_b64joser6�bytesr(�property�boolr;r!r!r!r"r5Vs

��r5cs\eZdZUdZe�d�Zeed<e	j
Zdeje
d�dd�Zeeefd��fd	d
�Z�ZS)�!KeyAuthorizationChallengeResponsez[Response to Challenges based on Key Authorization.

    :param str key_authorization:

    �keyAuthorization�key_authorization�KeyAuthorizationChallenge��chall�account_public_keyrcCs�|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 formedFrr6z8Mismatching token in key authorization: %r instead of %r�Z
hash_function�z=Mismatching thumbprint in key authorization: %r instead of %rT)rD�split�lenrr�encoder�	b64encode�
thumbprint�thumbprint_hash_function�decode)r0rGrH�partsrQr!r!r"�verify}s(����z(KeyAuthorizationChallengeResponse.verifyr,cst���}|�dd�|S)NrC)rr-r.r/rr!r"r-�s
z1KeyAuthorizationChallengeResponse.to_partial_json)r#r$r%r&rr<rDr'r(rZSHA256rR�JWKrArUrrr-r*r!r!rr"rBts

 rBc@s�eZdZUdZeZeed<eZe	e
ed<e
jZej
ed�dd�Zej
e
d�dd�Zejej
eed	�d
d��Zej
eeee
efd�d
d�ZdS)rEz�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
    �typ�response_cls)�account_keyrcCs&|�d�dt�|j|jd����S)zZGenerate Key Authorization.

        :param JWK account_key:
        :rtype str:

        r6rIrK)rOrrPrQrRrS�r0rYr!r!r"rD�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

        �rD)rXrDrZr!r!r"�response�s	�z"KeyAuthorizationChallenge.response�rY�kwargsrcKs
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�r0rYr^r!r!r"�
validation�s
z$KeyAuthorizationChallenge.validation)rY�argsr^rcOs"|�|�|j|g|�Ri|��fS)z�Generate response and validation.

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

        :param JWK account_key:
        :rtype: tuple

        )r\ra)r0rYrbr^r!r!r"�response_and_validation�s�z1KeyAuthorizationChallenge.response_and_validationN)r#r$r%r&�NotImplementedrWr'r(rXrrBrRrrVrDr\�abc�abstractmethodrrarrcr!r!r!r"rE�s
�
�rE)�	metaclassc@s*eZdZdZdZdeejed�dd�Z	dS)�
DNS01ResponsezACME dns-01 challenge response.zdns-01�DNS01)rG�domainrHrcCs|�||�}|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 str 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)rUrr)r0rGrjrHZverifiedr!r!r"�
simple_verify�s
zDNS01Response.simple_verifyN)
r#r$r%r&rWr'rrVrArlr!r!r!r"rh�srhc@sBeZdZdZeZejZdZej	e
ed�dd�Zeed�dd�Z
d	S)
rizACME dns-01 challenge.�_acme-challenge�rY�
unused_kwargsrcKs$t�t�|�|��d�������S)�SGenerate validation.

        :param JWK account_key:
        :rtype: str

        �utf-8)rrP�hashlib�sha256rDrO�digestrS�r0rYror!r!r"ras
��zDNS01.validation��namercCs|j�d|��S)z{Domain name for TXT validation record.

        :param str name: Domain name being validated.
        :rtype: str

        rI)�LABEL�r0rwr!r!r"�validation_domain_nameszDNS01.validation_domain_nameN)r#r$r%r&rhrXrWrxrrVrr'rarzr!r!r!r"ris
ric@s<eZdZdZdZdZdZddeej	e
eeed�d	d
�Z
dS)�HTTP01Responsez ACME http-01 challenge response.zhttp-01�Pz

	 N��HTTP01)rGrjrH�port�timeoutrc

Cs�|�||�st�d�dS|durF||jkrFt�d|�|d�|�7}|�|�}t�d|j|�ztj	|d|d�}Wn8tj
jy�}zt�d||�WYd}~dSd}~00d	|_
t�d
||j|j�|j�|j�}	|j|	k�r�t�d|j|	�dSdS)
a�Simple verify.

        :param challenges.SimpleHTTP chall: Corresponding challenge.
        :param str 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.
        :param int timeout: Timeout in seconds.

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

        rkFNz4Using non-standard port for http-01 verification: %sz:{0}zVerifying %s at %s...)rUr�zUnable to reach %s: %s�asciizReceived %s: %s. Headers: %szEKey authorization from response (%r) doesn't match HTTP response (%r)T)rUrr�PORTZwarning�format�urirW�requests�get�
exceptionsZRequestExceptionr�encoding�textZheaders�rstrip�WHITESPACE_CUTSETrD)
r0rGrjrHrr�r�Z
http_responserZchallenge_responser!r!r"rl/s6
�
	��zHTTP01Response.simple_verify)Nr})r#r$r%r&rWr�r�r'rrVr�intrArlr!r!r!r"r{s�

�r{c@sTeZdZdZeZejZdZee	d�dd��Z
e	e	d�dd�Zej
ee	d	�d
d�ZdS)
r~zACME http-01 challenge.z.well-known/acme-challenger,cCsd|jd|�d�S)zQPath (starting with '/') for provisioned resource.

        :rtype: str

        �/r6)�
URI_ROOT_PATHrOr4r!r!r"�pathqszHTTP01.path)rjrcCsd||jS)z�Create an URI to the provisioned resource.

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

        :param str domain: Domain name being verified.
        :rtype: str

        zhttp://)r�)r0rjr!r!r"r�zs
z
HTTP01.urirncKs
|�|�S)rpr[rur!r!r"ra�szHTTP01.validationN)r#r$r%r&r{rXrWr�r@r'r�r�rrVrrar!r!r!r"r~hsr~c	@s�eZdZdZdZdZdZdZee	d�dd��Z
deee
jeee
je
jfd�dd
�Zdeeeeee
jd�dd�Zee
jed�dd�Zddeejee
jeeeeed�dd�Zd	S)�TLSALPN01Responsez$ACME tls-alpn-01 challenge response.ztls-alpn-01i�s1.3.6.1.5.5.7.1.30.1s
acme-tls/1r,cCst�|j�d����S)z*Hash value stored in challenge certificaterq)rrrsrDrOrtr4r!r!r"�h�szTLSALPN01Response.hN�)rj�key�bitsrcCs\|durt��}|�tj|�dt�|jd�}tj|jd|d�}t	j
||gd|gd�|fS)a�Generate tls-alpn-01 certificate.

        :param str domain: Domain verified by the challenge.
        :param OpenSSL.crypto.PKey key: Optional private key used in
            certificate generation. If not provided (``None``), then
            fresh key will be generated.
        :param int bits: Number of bits for newly generated key.

        :rtype: `tuple` of `OpenSSL.crypto.X509` and `OpenSSL.crypto.PKey`

        NsDER:�hexT)Zcritical�value)Z	force_san�
extensions)r�PKeyZgenerate_keyZTYPE_RSA�codecsrOr�Z
X509Extension�ID_PE_ACME_IDENTIFIER_V1rZgen_ss_cert)r0rjr�r�Z	der_valueZacme_extensionr!r!r"�gen_cert�s
���zTLSALPN01Response.gen_cert)rj�hostrrcCsL|dur t�|�}t�d||�|dur.|j}tj|��||��|jgd�S)z�Probe tls-alpn-01 challenge certificate.

        :param str domain: domain being validated, required.
        :param str host: IP address used to probe the certificate.
        :param int port: Port used to probe the certificate.

        Nz%s resolved to %s)r�rrwZalpn_protocols)	�socketZ
gethostbynamerrr�rZ	probe_snirO�ACME_TLS_1_PROTOCOL)r0rjr�rr!r!r"�
probe_cert�s	
�zTLSALPN01Response.probe_cert)rj�certrcCs�t�|�}t�d|�d�|�t|�dks>|d��|��krBdSt|���D]0}|�	|�}|�
�dkrN|��}||jkSqNdS)aVerify tls-alpn-01 challenge certificate.

        :param str domain: Domain name being validated.
        :param OpensSSL.crypto.X509 cert: Challenge certificate.

        :returns: Whether the certificate was successfully verified.
        :rtype: bool

        zCertificate %s. SANs: %srsrLrFsUNDEF)
rZ _pyopenssl_cert_or_req_all_namesrrrtrN�lower�rangeZget_extension_countZ
get_extensionZget_short_name�get_datar�)r0rjr��names�iZext�datar!r!r"�verify_cert�s

� 
zTLSALPN01Response.verify_cert�	TLSALPN01)rGrjrHr�r�rrc
Cs~|�||�st�d�dS|durrz|j|||d�}Wn:tjyp}z tjt|�dd�WYd}~dSd}~00|�||�S)a�Simple verify.

        Verify ``validation`` using ``account_public_key``, optionally
        probe tls-alpn-01 certificate and check using `verify_cert`.

        :param .challenges.TLSALPN01 chall: Corresponding challenge.
        :param str domain: Domain name being validated.
        :param JWK account_public_key:
        :param OpenSSL.crypto.X509 cert: Optional certificate. If not
            provided (``None``) certificate will be retrieved using
            `probe_cert`.
        :param string host: IP address used to probe the certificate.
        :param int port: Port used to probe the certificate.


        :returns: ``True`` if and only if client's control of the domain has been verified.
        :rtype: bool

        rkFN)rjr�rT)�exc_info)rUrrr�r�Errorr'r�)r0rGrjrHr�r�rrr!r!r"rl�s
zTLSALPN01Response.simple_verify)Nr�)NN)NNN)r#r$r%r&rWr�r�r�r@r?r�r'rrr�r�r�X509r�r�rAr�rrVrlr!r!r!r"r��s,��

��
�r�c@sLeZdZdZeZejZeje	e
ejej
fd�dd�Zeed�dd��ZdS)	r�zACME tls-alpn-01 challenge.r]cKs,tt|�|��j|�d�tt|�d��d�S)a�Generate validation.

        :param JWK account_key:
        :param str domain: Domain verified by the challenge.
        :param OpenSSL.crypto.PKey cert_key: Optional private key used
            in certificate generation. If not provided (``None``), then
            fresh key will be generated.

        :rtype: `tuple` of `OpenSSL.crypto.X509` and `OpenSSL.crypto.PKey`

        Zcert_keyrj)r�rj)rr�r\r�r�r'r`r!r!r"ras
�zTLSALPN01.validationr,cCsttjd�ottjd�S)ai
        Check if TLS-ALPN-01 challenge is supported on this machine.
        This implies that a recent version of OpenSSL is installed (>= 1.0.2),
        or a recent cryptography version shipped with the OpenSSL library is installed.

        :returns: ``True`` if TLS-ALPN-01 is supported on this machine, ``False`` otherwise.
        :rtype: bool

        Zset_alpn_protosZset_alpn_select_callback)�hasattrr
Z
ConnectionZContextr!r!r!r"�is_supported(s
�zTLSALPN01.is_supportedN)r#r$r%r&r�rXrWrrVrrrr�r�ra�staticmethodrAr�r!r!r!r"r�s r�c@sreZdZdZdZdZejfejej	e
ejd�dd�Zejeje
d�dd	�Zeje
d
d�dd
�Zeed�dd�ZdS)�DNSzACME "dns" challenge.�dnsrm)rY�algr^rcKs(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_keysrq)�payloadr�r�)r�JWSZsignZ
json_dumpsrO)r0rYr�r^r!r!r"�gen_validation?s��zDNS.gen_validation)rarHrc
Csb|j|d�sdSz||�|j�d��kWStjy\}zt�d|�WYd}~dSd}~00dS)zwCheck validation.

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

        )r�Frqz&Checking validation for DNS failed: %sN)rUZ
json_loadsr�rSrZDeserializationErrorrr)r0rarHrr!r!r"�check_validationNs
�zDNS.check_validation�DNSResponser]cKst|j|fi|��d�S)z�Generate response.

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

        :rtype: DNSResponse

        )ra)r�r�r`r!r!r"�gen_response_s	zDNS.gen_responservcCsd�|j|�S)zgDomain name for TXT validation record.

        :param str name: Domain name being validated.

        z{0}.{1})r�rxryr!r!r"rzjszDNS.validation_domain_nameN)r#r$r%r&rWrxrZRS256rVZJWASignaturerr�r�rAr�r�r'rzr!r!r!r"r�7s�r�c@sFeZdZUdZdZejdejjd�Z	eje
d<dejed�dd�Z
d	S)
r�z@ACME "dns" challenge response.

    :param JWS validation:

    r�ra)r9r�rFcCs|�|j|�S)z~Check validation.

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

        :rtype: bool

        )r�ra)r0rGrHr!r!r"r�~s	zDNSResponse.check_validationN)r#r$r%r&rWrr<r�rrar(rVrAr�r!r!r!r"r�ss
r�)1r&rer�r=rrZloggingr��typingrrrrrrrr	r
Zcryptography.hazmat.primitivesrZjosepyrZOpenSSLrr
r�ZacmerrZ	getLoggerr#rrZTypedJSONObjectWithFieldsrr+rr5rB�ABCMetarE�registerrhrir{r~r�r�r�r�r!r!r!r"�<module>s^

2AH'%;

Youez - 2016 - github.com/yon3zu
LinuXploit