%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/acme/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/acme/__pycache__/challenges.cpython-312.pyc

�

M/�e�W���dZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZddlmZddlm
Z
dd	lmZdd
lmZddlmZddlmZddlZdd
lmZddlmZddlZddlmZddlmZej8e�Zedd��ZGd�dej@�Z!Gd�dej@�Z"Gd�de!�Z#Gd�de!�Z$Gd�de"�Z%Gd�de$ejL��Z'e"jPGd �d!e%��Z)e!jPGd"�d#e'��Z*e"jPGd$�d%e%��Z+e!jPGd&�d'e'��Z,e"jPGd(�d)e%��Z-e!jPGd*�d+e'��Z.e!jPGd,�d-e$��Z/e"jPGd.�d/e"��Z0y)0z&ACME Identifier Validation Challenges.�N)�Any)�cast)�Dict)�Mapping)�Optional)�Tuple)�Type)�TypeVar)�Union)�hashes)�crypto)�SSL)�crypto_util)�errors�GenericChallenge�	Challenge)�boundc	�t��eZdZUdZiZeeedfed<e	dee
deeefde
e
dff�fd��Z�xZS)rzACME challenge.�TYPES�cls�jobj�return�UnrecognizedChallengec����	ttt�|�
|��S#tj
$r4}tj|�tj|�cYd}~Sd}~wwxYw�N)	rr�super�	from_json�jose�UnrecognizedTypeError�logger�debugr)rr�error�	__class__s   ��1/usr/lib/python3/dist-packages/acme/challenges.pyrzChallenge.from_json%sS���	9��(�%�'�*;�D�*A�B�B���)�)�	9��L�L���(�2�2�4�8�8��	9�s� �A'�)A"�A'�"A')�__name__�
__module__�__qualname__�__doc__rr�strr	�__annotations__�classmethodrrrrr�
__classcell__�r#s@r$rr sc����*,�E�4��T�+�&�&�'�,��9�t�,�-�9���S��)�9�.3�4D�F]�4]�.^�9��9�c�R��eZdZUdZiZeeedfed<deee	ff�fd�Z
�xZS)�ChallengeResponsezACME challenge response.rrc�\��t�|��}|j|jd�|Sr)r�to_partial_json�pop�type_field_name��selfrr#s  �r$r2z!ChallengeResponse.to_partial_json4s+����w�&�(������%�%�t�,��r.)r%r&r'r(rrr)r	r*rr2r,r-s@r$r0r0/s9���"�24�E�4��T�-�.�.�/�4���c�3�h���r.r0c���eZdZUdZeeefed<deeefddf�fd�Z	deeeffd�Z
edeeefddfd��Z�xZ
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.

    rrNc�P��t�|��tj|d|�y)Nr)r�__init__�object�__setattr__r5s  �r$r9zUnrecognizedChallenge.__init__Js ���
�������4���.r.c��|jSr)r�r6s r$r2z%UnrecognizedChallenge.to_partial_jsonNs���y�y�r.c��||�Sr�)rrs  r$rzUnrecognizedChallenge.from_jsonQs���4�y�r.)r%r&r'r(rr)rr*rr9r2r+rr,r-s@r$rr<st���
��s�C�x�.��/�W�S�#�X�.�/�4�/���c�3�h�����W�S�#�X�.��3J���r.rc	��eZdZUdZdZ	ejdejejejed����Zee
d<edefd��Zy	)
�_TokenChallengez3Challenge with token.

    :ivar bytes token:

    g0@�tokenT)�size�minimum)�encoder�decoderrc�>�d|jvxrd|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..�/)rBr=s r$�
good_tokenz_TokenChallenge.good_tokenes!���D�J�J�&�A�4�t�z�z�+A�Ar.N)r%r&r'r(�
TOKEN_SIZEr�field�encode_b64jose�	functools�partial�decode_b64joserB�bytesr*�property�boolrIr?r.r$rArAVss���
�J�5��4�:�:���,�,�6G�i�6G�6G����j�$�7@�A�E�5�A�
�B�D�B��Br.rAc���eZdZUdZej
d�Zeed<e	jZdddejde
fd�Zdeeeff�fd	�Z�xZS)
�!KeyAuthorizationChallengeResponsez[Response to Challenges based on Key Authorization.

    :param str key_authorization:

    �keyAuthorization�key_authorization�chall�KeyAuthorizationChallenge�account_public_keyrc���|jjd�}t|�dk7r!tj	d|j�y|d|jd�k7r*tj	d|d|jd��yt
j|j|j���j�}|d	|k7rtj	d
|d|�yy)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 formedFrrBz8Mismatching token in key authorization: %r instead of %r��
hash_function�z=Mismatching thumbprint in key authorization: %r instead of %rT)rV�split�lenr r!�encoder�	b64encode�
thumbprint�thumbprint_hash_function�decode)r6rWrY�partsrds     r$�verifyz(KeyAuthorizationChallengeResponse.verify}s����&�&�,�,�S�1���u�:��?��L�L�D��/�/�
1����8�u�|�|�G�,�,��L�L�,�-2�1�X�u�|�|�G�7L�
N���^�^�$6�$A�$A��7�7�%B�%9�:�:@�&�(�	���8�z�!��L�L�,�-2�1�X�z�
C��r.c�H��t�|��}|jdd�|S)NrU)rr2r3r5s  �r$r2z1KeyAuthorizationChallengeResponse.to_partial_json�s$����w�&�(�����#�T�*��r.)r%r&r'r(rrKrVr)r*r�SHA256re�JWKrRrhrrr2r,r-s@r$rTrTtse����
(�T�Z�Z�(:�;��s�;�%�}�}���7��T�X�X��Z^��@��c�3�h���r.rTc
��eZdZUdZeZeed<eZe	e
ed<e
jZdejdefd�Zdejde
fd�Zej"dejdedefd	��Zdejd
ededee
effd�Zy)
rXz�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_keyrc��|jd�dztj|j|j���j�zS)zZGenerate Key Authorization.

        :param JWK account_key:
        :rtype str:

        rBr[r])rbrrcrdrerf�r6ros  r$rVz+KeyAuthorizationChallenge.key_authorization�sO���{�{�7�#�c�)�D�N�N��"�"�"�;�;�
#�
=�->�>D�f�h�G�	Gr.c�D�|j|j|���S)z�Generate response to the challenge.

        :param JWK account_key:

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

        �rV)rnrVrqs  r$�responsez"KeyAuthorizationChallenge.response�s,��� � �"�4�4�[�A�!�C�	Cr.�kwargsc��t��)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.

        )�NotImplementedError�r6rorus   r$�
validationz$KeyAuthorizationChallenge.validation�s
��"�#�#r.�argsc�P�|j|�|j|g|��i|��fS)z�Generate response and validation.

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

        :param JWK account_key:
        :rtype: tuple

        )rtry)r6rorzrus    r$�response_and_validationz1KeyAuthorizationChallenge.response_and_validation�s2���
�
�k�*������=�d�=�f�=�?�	?r.N)r%r&r'r(�NotImplementedrmr)r*rnr	rTrerrkrVrt�abc�abstractmethodrryrr|r?r.r$rXrX�s�����C���<J�L�$�8�9�J�)�B�B��	G�T�X�X�	G�#�	G�
C�D�H�H�
C�1R�
C�	���$�d�h�h�$�#�$�#�$��$�?�4�8�8�?�C�?�SV�?�%*�+L�c�+Q�%R�?r.rX)�	metaclassc�@�eZdZdZdZdddedejdefd�Z	y	)
�
DNS01ResponsezACME dns-01 challenge response.zdns-01rW�DNS01�domainrYrc�X�|j||�}|stjd�|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)rhr r!)r6rWr�rY�verifieds     r$�
simple_verifyzDNS01Response.simple_verify�s*�� �;�;�u�&8�9����L�L�O�P��r.N)
r%r&r'r(rmr)rrkrRr�r?r.r$r�r��s0��)�
�C��7��C��T�X�X��Z^�r.r�c�j�eZdZdZeZejZdZ	dejde
defd�Zdedefd�Z
y	)
r�zACME dns-01 challenge.�_acme-challengero�
unused_kwargsrc���tjtj|j	|�jd��j
��j�S)�SGenerate validation.

        :param JWK account_key:
        :rtype: str

        �utf-8)rrc�hashlib�sha256rVrb�digestrf�r6ror�s   r$ryzDNS01.validationsG���~�~�g�n�n�T�-C�-C��.�����*�*0�&�(�4�4:�F�H�	=r.�namec�$�|j�d|��S)z{Domain name for TXT validation record.

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

        r[)�LABEL�r6r�s  r$�validation_domain_namezDNS01.validation_domain_names���*�*��Q�t�f�%�%r.N)r%r&r'r(r�rnrmr�rrkrr)ryr�r?r.r$r�r�sN�� � �L�
�
�
�C��E�C�=�d�h�h�=��=��=�&�3�&�3�&r.r�c
�^�eZdZdZdZdZ	dZ		dddded	ejd
e
ededefd
�Z
y)�HTTP01Responsez ACME http-01 challenge response.zhttp-01�Pz

	 NrW�HTTP01r�rY�port�timeoutrc���|j||�stjd�y|�9||jk7r*tj	d|�|dj|�z
}|j
|�}tjd|j|�	tj|d|��}d	|_
tjd
||j|j�|jj!|j"�}	|j$|	k7r"tjd|j$|	�yy#tjj$r!}tjd||�Yd}~yd}~wwxYw)
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

        r�FNz4Using non-standard port for http-01 verification: %sz:{0}zVerifying %s at %s...)rhr�zUnable to reach %s: %s�asciizReceived %s: %s. Headers: %szEKey authorization from response (%r) doesn't match HTTP response (%r)T)rhr r!�PORT�warning�format�urirm�requests�get�
exceptions�RequestExceptionr"�encoding�text�headers�rstrip�WHITESPACE_CUTSETrV)
r6rWr�rYr�r�r��
http_responser"�challenge_responses
          r$r�zHTTP01Response.simple_verify/sG�� �{�{�5�"4�5��L�L�O�P��
����	�	� 1��N�N�F��
N��f�m�m�D�)�)�F��i�i�������,�e�i�i��=�	�$�L�L��U�G�L�M�")�
�����3�]�"�'�'��)>�)>�	@�+�/�/�6�6�t�7M�7M�N���!�!�%7�7��L�L�.�/3�/E�/E�+�
-����-�"�"�3�3�	��L�L�1�3��>���	�s�D9�9E7�E2�2E7)N�)r%r&r'r(rmr�r�r)rrkr�intrRr�r?r.r$r�r�s`��*�
�C�
�D��"��O�BD�6�8�6�S�6�d�h�h�6�$�S�M�6�;>�6�HL�6r.r�c��eZdZdZeZejZdZ	ede	fd��Z
de	de	fd�Zdejdede	fd	�Zy
)r�zACME http-01 challenge.z.well-known/acme-challengerc�J�d|jzdz|jd�zS)zQPath (starting with '/') for provisioned resource.

        :rtype: str

        �/rB)�
URI_ROOT_PATHrbr=s r$�pathzHTTP01.pathqs(���T�'�'�'�#�-����G�0D�D�Dr.r�c�&�d|z|jzS)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�)r6r�s  r$r�z
HTTP01.urizs���6�!�D�I�I�-�-r.ror�c�$�|j|�S)r�rsr�s   r$ryzHTTP01.validation�s���%�%�k�2�2r.N)r%r&r'r(r�rnrmr�rQr)r�r�rrkrryr?r.r$r�r�hsj��!�!�L�
�
�
�C�0�M�<�
�E�c�E��E�
.�#�
.�#�
.�3�d�h�h�3��3��3r.r�c�h�eZdZdZdZdZ	dZdZede	fd��Z
dd	ed
ee
jdedee
j"e
jffd�Z		dd	ed
eedeede
j"fd�Zd	ede
j"defd�Z		dddd	edej.dee
j"d
eedeedefd�Zy)�TLSALPN01Responsez$ACME tls-alpn-01 challenge response.ztls-alpn-01i�s1.3.6.1.5.5.7.1.30.1s
acme-tls/1rc�z�tj|jjd��j	�S)z*Hash value stored in challenge certificater�)r�r�rVrbr�r=s r$�hzTLSALPN01Response.h�s-���~�~�d�4�4�;�;�G�D�E�L�L�N�Nr.Nr��key�bitsc�2�|�4tj�}|jtj|�dt	j
|jd�z}tj|jd|��}tj||gd|g��|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`

        sDER:�hexT)�critical�value)�	force_san�
extensions)r
�PKey�generate_key�TYPE_RSA�codecsrbr��
X509Extension�ID_PE_ACME_IDENTIFIER_V1r�gen_ss_cert)r6r�r�r��	der_value�acme_extensions      r$�gen_certzTLSALPN01Response.gen_cert�s����;��+�+�-�C����V�_�_�d�3��f�m�m�D�F�F�E�:�:�	��-�-�d�.K�.K�7;�9�N���&�&�s�V�H��3A�2B�D�EH�I�	Ir.�hostr�c��|�,tj|�}tjd||�|�|j}tj|j�||j�|jg��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.

        z%s resolved to %s)r�r�r��alpn_protocols)	�socket�
gethostbynamer r!r�r�	probe_snirb�ACME_TLS_1_PROTOCOL)r6r�r�r�s    r$�
probe_certzTLSALPN01Response.probe_cert�sk���<��'�'��/�D��L�L�,�f�d�;��<��9�9�D��$�$�$�+�+�-�d�����59�5M�5M�4N�P�	Pr.�certc��tj|�}tjd|j	d�|�t|�dk7s$|dj
�|j
�k7ryt|j��D]G}|j|�}|j�dk(s�(|j�}||jk(cSy)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: %sr�r_rFsUNDEF)
r� _pyopenssl_cert_or_req_all_namesr r!r�ra�lower�range�get_extension_count�
get_extension�get_short_name�get_datar�)r6r�r��names�i�ext�datas       r$�verify_certzTLSALPN01Response.verify_cert�s����<�<�T�B��	���/��[�[��*�E�	3��u�:��?�e�A�h�n�n�.�&�,�,�.�@���t�/�/�1�2�	&�A��$�$�Q�'�C��!�!�#�x�/��|�|�~���t�v�v�~�%�
	&�r.rW�	TLSALPN01rYc�$�|j||�stjd�y|�	|j|||��}|j||�S#tj
$r*}tjt
|�d��Yd}~yd}~wwxYw)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

        r�FN)r�r�r�T)�exc_info)rhr r!r�r�Errorr)r�)r6rWr�rYr�r�r�r"s        r$r�zTLSALPN01Response.simple_verify�s���,�{�{�5�"4�5��L�L�O�P���<�
����f�4�d��K��
�����-�-��	�<�<�
����S��Z�$��7���
�s�A�B�% B
�
B)Ni)NN)NNN)r%r&r'r(rmr�r�r�rQrPr�r)rr
r�r�r�X509r�r�rRr�rrkr�r?r.r$r�r��s7��.�
�C��D�� 7��'��
�O�5�O��O�I�s�I��&�+�+�)>�I�S�I��F�K�K����4�5�I�0=A�)-�P��P�H�S�M�P�!�#��P�28�+�+�P�$�#��V�[�[��T��>QU�,0�!.�;�!.��!.�QU�QY�QY�!.�$�V�[�[�1�!.�@H��
�!.�$�S�M�!.�59�!.r.r�c��eZdZdZeZejZdejde	de
ejejffd�Zedefd��Zy)r�zACME tls-alpn-01 challenge.rorurc	��tt|j|��j|j	d�tt
|j	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`

        �cert_keyr�)r�r�)rr�rtr�r�r)rxs   r$ryzTLSALPN01.validationsM���%�t�}�}�[�'A�B�K�K��
�
�:�&���V�Z�Z��1�2�L�4�	4r.c�n�ttjd�xrttjd�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

        �set_alpn_protos�set_alpn_select_callback)�hasattrr�
Connection�Contextr?r.r$�is_supportedzTLSALPN01.is_supported(s.������(9�:�E��C�K�K�)C�D�	Fr.N)r%r&r'r(r�rnrmrrkrrr
r�r�ry�staticmethodrRr�r?r.r$r�r�sf��%�$�L�
�
�
�C�4�d�h�h�4�#�4�%����U[�U`�U`�H`�Ba�4�"�F�$�F��Fr.r�c	��eZdZdZdZdZ	ejfdejdejde
dejfd�Zd	ejd
ejde
fd�Zdejde
ddfd
�Zdedefd�Zy)�DNSzACME "dns" challenge.�dnsr�ro�algrurc��tjjd|jd��j	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)�	sort_keysr�)�payloadr�r�r?)r�JWS�sign�
json_dumpsrb)r6ror�rus    r$�gen_validationzDNS.gen_validation?sD���x�x�}�}�0��O�O�d�O�3�:�:�7�C���0�(.�0�	0r.ryrYc���|j|��sy	||j|jjd��k(S#tj
$r }tjd|�Yd}~yd}~wwxYw)zwCheck validation.

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

        )r�Fr�z&Checking validation for DNS failed: %sN)rh�
json_loadsr�rfr�DeserializationErrorr r!)r6ryrYr"s    r$�check_validationzDNS.check_validationNsr��� � �%7� �8��	��4�?�?��"�"�)�)�'�2�4�4�
4���(�(�	��L�L�A�5�I���	�s�,A�A5�A0�0A5�DNSResponsec�<�t|j|fi|����S)z�Generate response.

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

        :rtype: DNSResponse

        )ry)rr�rxs   r$�gen_responsezDNS.gen_response_s"���&9�d�&9�&9�+�&P��&P�Q�Qr.r�c�:�dj|j|�S)zgDomain name for TXT validation record.

        :param str name: Domain name being validated.

        z{0}.{1})r�r�r�s  r$r�zDNS.validation_domain_namejs������
�
�D�1�1r.N)r%r&r'r(rmr�r�RS256rk�JWASignaturerr�r�rRrrr)r�r?r.r$r�r�7s����
�C��E�C�MQ�Z�Z�
0�$�(�(�
0��9J�9J�
0�!$�
0�)-���
0��4�8�8������VZ��"	R����	R�C�	R�M�	R�2�3�2�3�2r.r�c��eZdZUdZdZejdejj��Z	eje
d<dddejdefd	�Z
y
)rz@ACME "dns" challenge response.

    :param JWS validation:

    r�ry)rFrWr�rYrc�:�|j|j|�S)z~Check validation.

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

        :rtype: bool

        )rry)r6rWrYs   r$rzDNSResponse.check_validation~s���%�%�d�o�o�7I�J�Jr.N)r%r&r'r(rmrrKr�rryr*rkrRrr?r.r$rrssU���
�C�%�4�:�:�l�D�H�H�<N�<N�O�J����O�	K�e�	K����	K�d�	Kr.r)1r(r~r�rMr��loggingr��typingrrrrrrr	r
r�cryptography.hazmat.primitivesr�josepyr�OpenSSLr
rr��acmerr�	getLoggerr%r r�TypedJSONObjectWithFieldsrr0rrArT�ABCMetarX�registerr�r�r�r�r�r�r�rr?r.r$�<module>rs���,�
�
����
����������1�������	��	�	�8�	$���-�[�A��9��.�.�9�
��6�6�
��I��4B�i�B�<,�(9�,�d>?��3�;�;�>?�B����5����4���&�%�&��&�8���E�6�E��E�P���$3�
&�$3��$3�N���}.�9�}.��}.�@���"F�)�"F��"F�J���82�/�82��82�v���K�#�K��Kr.

Zerion Mini Shell 1.0