Your IP : 13.59.236.101


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/urllib3/util/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/urllib3/util/__pycache__/ssl_.cpython-311.pyc

�

��bg,K���UddlmZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
ddlmZmZddlmZmZdZdZd	Zd	Zd	Zd
gZejeeeeefZeee
d�ZdXd�ZdYd�Z ej!r$ddl"m#Z#ddl$m%Z%m&Z&ddl'mZ(Gd�de&d	���Z)iZ*de+d <	ddl"Z"dd!l"m,Z,mZm-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4mZm5Z5e1Z6er7e e/e0ej7j8ej9ej7j8d"krej:nd��sd	Zd#D]*Z;	e<e5e;��e*e<e"d$e;����<� #e=$rY�'wxYwddl'mZn#e>$rd%Z-d&Z.d'Z3d(Z4dxZ6Z1d)Z2YnwxYwej?de@dfZAdZd.�ZBd[d2�ZCd\d3�ZD						d]d^d=�ZEejF												d_d`dN���ZGejF												d_dadP���ZG												dbdadQ�ZGdcdT�ZHdddV�ZI	dedfdW�ZJdS)g�)�annotationsN)�	unhexlify)�md5�sha1�sha256�)�ProxySchemeUnsupported�SSLError�)�_BRACELESS_IPV6_ADDRZ_RE�_IPV4_REFzhttp/1.1)� �(�@�implementation_name�str�version_info�_TYPE_VERSION_INFO�pypy_version_info�_TYPE_VERSION_INFO | None�return�boolc��|dkr|dko|dkS|dkr0|dd�}|d}|dkr|dkp|dko|d	kp|d
kSdS)a�Return True for CPython 3.8.9+, 3.9.3+ or 3.10+ and PyPy 7.3.8+ where
    setting SSLContext.hostname_checks_common_name to False works.

    Outside of CPython and PyPy we don't know which implementations work
    or not so we conservatively use our hostname matching as we know that works
    on all implementations.

    https://github.com/urllib3/urllib3/issues/2192#issuecomment-821832963
    https://foss.heptapod.net/pypy/pypy/-/issues/3539
    �pypy)���)rr�cpythonNr�	)rrr)r�
F�)rrr�major_minor�micros     �H/opt/cloudlinux/venv/lib64/python3.11/site-packages/urllib3/util/ssl_.py�_is_bpo_43522_fixedr%s����f�$�$� �I�-�H�,�&�2H�H�	�	�	)�	)�"�2�A�2�&���Q���
�F�
"�
1�u��z�
&��v�%�4�%�1�*�
&��g�%�	
��u��openssl_version�openssl_version_number�intc�b�|�d��}|dk}|o|pt|||��S)NzOpenSSL i�)�
startswithr%)r'r(rrr�
is_openssl�is_openssl_issue_14579_fixeds       r$�(_is_has_never_check_common_name_reliabler.:sK��!�+�+�J�7�7�J�
$:�Z�#G� ���$�	U��2�L�BS�T�T�r&)�
VerifyMode)�Literal�	TypedDict)�SSLTransportc�.�eZdZUded<ded<ded<dS)�_TYPE_PEER_CERT_RET_DICTztuple[tuple[str, str], ...]�subjectAltNamez'tuple[tuple[tuple[str, str], ...], ...]�subjectr�serialNumberN)�__name__�
__module__�__qualname__�__annotations__r!r&r$r4r4Ws6�������3�3�3�3�8�8�8�8������r&r4)�totalzdict[int, int]�_SSL_VERSION_TO_TLS_VERSION)�
CERT_REQUIRED�HAS_NEVER_CHECK_COMMON_NAME�OP_NO_COMPRESSION�OP_NO_TICKET�OPENSSL_VERSION�OPENSSL_VERSION_NUMBER�PROTOCOL_TLS�PROTOCOL_TLS_CLIENT�OP_NO_SSLv2�OP_NO_SSLv3�
SSLContext�
TLSVersionr)�TLSv1�TLSv1_1�TLSv1_2�	PROTOCOL_ii@ii��cert�bytes | None�fingerprint�Nonec���|�td���|�dd�����}t|��}t�|��}|std|�����t
|�����}||�����}tj
||��s(td|�d|����d����dS)	z�
    Checks if given fingerprint matches the supplied certificate.

    :param cert:
        Certificate as bytes object.
    :param fingerprint:
        Fingerprint as string of hexdigits, can be interspersed by colons.
    NzNo certificate for the peer.�:�zFingerprint of invalid length: z&Fingerprints did not match. Expected "z", got "�")r
�replace�lower�len�HASHFUNC_MAP�getr�encode�digest�hmac�compare_digest�hex)rOrQ�
digest_length�hashfunc�fingerprint_bytes�cert_digests      r$�assert_fingerprintre�s���|��5�6�6�6��%�%�c�2�.�.�4�4�6�6�K���$�$�M����
�.�.�H��H��F��F�F�G�G�G�"�+�"4�"4�"6�"6�7�7���(�4�.�.�'�'�)�)�K���{�,=�>�>�
��^�[�^�^�+�/�/�J[�J[�^�^�^�
�
�	
�
�
r&�	candidate�None | int | strr/c��|�tSt|t��r2tt|d��}|�ttd|z��}|S|S)a�
    Resolves the argument to a numeric constant, which can be passed to
    the wrap_socket function/method from the ssl module.
    Defaults to :data:`ssl.CERT_REQUIRED`.
    If given a string it is assumed to be the name of the constant in the
    :mod:`ssl` module or its abbreviation.
    (So you can specify `REQUIRED` instead of `CERT_REQUIRED`.
    If it's neither `None` nor a string we assume it is already the numeric
    constant which can directly be passed to wrap_socket.
    N�CERT_)r>�
isinstancer�getattr�ssl�rf�ress  r$�resolve_cert_reqsro�sW�������)�S�!�!���c�9�d�+�+���;��#�w��2�3�3�C��
��r&c���|�tSt|t��rJtt|d��}|�ttd|z��}tjt|��S|S)z 
    like resolve_cert_reqs
    NrM)rDrjrrkrl�typing�castr)rms  r$�resolve_ssl_versionrs�sd�������)�S�!�!�%��c�9�d�+�+���;��#�{�Y�6�7�7�C��{�3��$�$�$��r&�ssl_version�
int | None�	cert_reqs�options�ciphers�
str | None�ssl_minimum_version�ssl_maximum_version�ssl.SSLContextc��t�td���|dttfvry|�|�t	d���t
�|tj��}t
�|tj	��}tjdtd���tt��}|�||_
ntj|_
|�||_|r|�|��|�t"jn|}|�*d}|t&z}|t(z}|t*z}|t,z}|xj|zc_|t"jkst0jdkrt5|d	d��	�d
|_|t"jkrt8s||_d
|_nd|_||_	d|_n#t@$rYnwxYwtC|d��r(tDj#�d
��}|r||_$|S)acCreates and configures an :class:`ssl.SSLContext` instance for use with urllib3.

    :param ssl_version:
        The desired protocol version to use. This will default to
        PROTOCOL_SSLv23 which will negotiate the highest protocol that both
        the server and your installation of OpenSSL support.

        This parameter is deprecated instead use 'ssl_minimum_version'.
    :param ssl_minimum_version:
        The minimum version of TLS to be used. Use the 'ssl.TLSVersion' enum for specifying the value.
    :param ssl_maximum_version:
        The maximum version of TLS to be used. Use the 'ssl.TLSVersion' enum for specifying the value.
        Not recommended to set to anything other than 'ssl.TLSVersion.MAXIMUM_SUPPORTED' which is the
        default value.
    :param cert_reqs:
        Whether to require the certificate verification. This defaults to
        ``ssl.CERT_REQUIRED``.
    :param options:
        Specific OpenSSL options. These default to ``ssl.OP_NO_SSLv2``,
        ``ssl.OP_NO_SSLv3``, ``ssl.OP_NO_COMPRESSION``, and ``ssl.OP_NO_TICKET``.
    :param ciphers:
        Which cipher suites to allow the server to select. Defaults to either system configured
        ciphers if OpenSSL 1.1.1+, otherwise uses a secure default set of ciphers.
    :returns:
        Constructed SSLContext object with specified options
    :rtype: SSLContext
    Nz7Can't create an SSLContext object without an ssl modulezZCan't specify both 'ssl_version' and either 'ssl_minimum_version' or 'ssl_maximum_version'zk'ssl_version' option is deprecated and will be removed in urllib3 v2.1.0. Instead use 'ssl_minimum_version'r)�category�
stacklevelr)rr��post_handshake_authTF�keylog_filename�
SSLKEYLOGFILE)%rH�	TypeErrorrDrE�
ValueErrorr=r[rI�MINIMUM_SUPPORTED�MAXIMUM_SUPPORTED�warnings�warn�DeprecationWarning�minimum_versionrL�maximum_version�set_ciphersrlr>rFrGr@rArw�sysrrkr��IS_PYOPENSSL�verify_mode�check_hostname�hostname_checks_common_name�AttributeError�hasattr�os�environr�)rtrvrwrxrzr{�context�
sslkeylogfiles        r$�create_urllib3_contextr��sZ��F���Q�R�R�R��4��/B�C�C�C��*�.A�.M��A���
�#>�"A�"A��Z�9�#�#��#>�"A�"A��Z�9�#�#��
�M�O�+��	
�
�
�
��,�-�-�G��&�"5����",�"4����&�"5����%����G�$�$�$�&/�%6��!�!�I�I������;����;���	�$�$��
	�<����O�O�w��O�O�	�S�&�&�&�#�*:�i�*G�*G�W��&��N�N�
�N�'+��#��C�%�%�%�l�%�'���!%����!&���'���
�.3��+�+���
�
�
���
����
�w�)�*�*�4��
����7�7�
��	4�&3�G�#��Ns�*F2�2
F?�>F?.�sock�
socket.socket�keyfile�certfile�ca_certs�server_hostname�ssl_context�ssl.SSLContext | None�ca_cert_dir�key_password�ca_cert_data�None | str | bytes�
tls_in_tls�Literal[False]�
ssl.SSLSocketc
��dS�Nr!�
r�r�r�rvr�r�rtrxr�r�r�r�r�s
             r$�ssl_wrap_socketr�h�	�� �Cr&� ssl.SSLSocket | SSLTransportTypec
��dSr�r!r�s
             r$r�r�{r�r&c
�$�|}
|
�t|||���}
|s|	s|r;	|
�||	|��nH#t$r}t|��|�d}~wwxYw|�$t	|
d��r|
���|r |
�t
|��rtd���|r0|
�|
�||��n|
�|||
��	|
�t��n#t$rYnwxYwt||
||��}|S)a
    All arguments except for server_hostname, ssl_context, and ca_cert_dir have
    the same meaning as they do when using :func:`ssl.wrap_socket`.

    :param server_hostname:
        When SNI is supported, the expected hostname of the certificate
    :param ssl_context:
        A pre-made :class:`SSLContext` object. If none is provided, one will
        be created using :func:`create_urllib3_context`.
    :param ciphers:
        A string of ciphers we wish the client to support.
    :param ca_cert_dir:
        A directory containing CA certificates in multiple separate files, as
        supported by OpenSSL's -CApath flag or the capath argument to
        SSLContext.load_verify_locations().
    :param key_password:
        Optional password if the keyfile is encrypted.
    :param ca_cert_data:
        Optional string containing CA certificates in PEM format suitable for
        passing as the cadata parameter to SSLContext.load_verify_locations()
    :param tls_in_tls:
        Use SSLTransport to wrap the existing socket.
    N)rx�load_default_certsz5Client private key is encrypted, password is required)r��load_verify_locations�OSErrorr
r�r��_is_key_file_encrypted�load_cert_chain�set_alpn_protocols�ALPN_PROTOCOLS�NotImplementedError�_ssl_wrap_socket_impl)r�r�r�rvr�r�rtrxr�r�r�r�r�r��e�ssl_socks                r$r�r��su��L�G���)��i��Q�Q�Q���%�;�%�,�%�	%��)�)�(�K��N�N�N�N���	%�	%�	%��1�+�+�1�$�����	%����
�	���2F�!G�!G�	��"�"�$�$�$�
�P�<�'�,B�7�,K�,K�'��N�O�O�O��E����#�#�H�g�6�6�6�6��#�#�H�g�|�D�D�D�
��"�"�>�2�2�2�2���
�
�
���
����%�T�7�J��P�P�H��Os'�6�
A�A�A�C.�.
C;�:C;�hostname�str | bytesc��t|t��r|�d��}tt	j|��pt
j|����S)z�Detects whether the hostname given is an IPv4 or IPv6 address.
    Also detects IPv6 addresses with Zone IDs.

    :param str hostname: Hostname to examine.
    :return: True if the hostname is an IP address, False otherwise.
    �ascii)rj�bytes�decoderr
�matchr)r�s r$�is_ipaddressr��sP���(�E�"�"�,��?�?�7�+�+�����x�(�(�T�,D�,J�8�,T�,T�U�U�Ur&�key_filec��t|��5}|D]}d|vrddd��dS�	ddd��n#1swxYwYdS)z*Detects if a key file is encrypted or not.�	ENCRYPTEDNTF)�open)r��f�lines   r$r�r��s���	
�h����1��	�	�D��d�"�"��	��������#�	��������������������5s�
5�5�9�9c��|r;tstd���tj|��t|||��S|�||���S)Nz0TLS in TLS requires support for the 'ssl' module)r�)r2r	�$_validate_ssl_context_for_tls_in_tls�wrap_socket)r�r�r�r�s    r$r�r��sh���@��	�(�B���
�	�9�+�F�F�F��D�+��?�?�?��"�"�4��"�I�I�Ir&)rrrrrrrr)r'rr(r)rrrrrrrr)rOrPrQrrrR)rfrgrr/)rfrgrr))NNNNNN)rtrurvrurwrurxryrzrur{rurr|)............)r�r�r�ryr�ryrvrur�ryr�ryrtrurxryr�r�r�ryr�ryr�r�r�r�rr�)r�r�r�ryr�ryrvrur�ryr�ryrtrurxryr�r�r�ryr�ryr�r�r�rrr�)NNNNNNNNNNNF)r�r�rr)r�rrrr�)
r�r�r�r|r�rr�ryrr�)K�
__future__rr^r��socketr�rqr��binasciir�hashlibrrr�
exceptionsr	r
�urlrr
rHr2r?r��IS_SECURETRANSPORTr��Tupler)rrrZr%r.�
TYPE_CHECKINGrlr/�typing_extensionsr0r1�ssltransport�SSLTransportTyper4r=r;r>r@rArBrCrDrErFrGrI�PROTOCOL_SSLv23�implementation�namerr�attrrkr��ImportError�Unionr��_TYPE_PEER_CERT_RETrerorsr��overloadr�r�r�r�r!r&r$�<module>r�s4��"�"�"�"�"�"�"�����	�	�	�	�
�
�
�
�
�
�
�
�
�
�
�
�����������%�%�%�%�%�%�%�%�%�%�9�9�9�9�9�9�9�9�3�3�3�3�3�3�3�3�
�
���#����������\�#�s�C��c�"9�:���T�v�.�.������<����,
��
�������4�4�4�4�4�4�4�4�>�>�>�>�>�>������9�E�����/1��0�0�0�0�/��J�J�J�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�#�O�#�,�+S�+S��������!$�!3�!8�F�!B�!B�����,�,�,�',�#�0����	�LS�G��D�M�M�'����5G��5G�5G�(H�(H�I�I���	�	�	��H�	����+�*�*�*�*�*�*���������L��K��K�%&�&�O�l�����
�����l�#=�u�d�#J�K��
�
�
�
�<����.
�
�
�
�"#� ���&*�&*�
K�K�K�K�K�\������"%�!��),�!�"�'*�!$��������$������"%�!��),�!�"�'*���������(�� ��"&�"��)-�"�#�'+��H�H�H�H�H�V
V�
V�
V�
V�����#'�	J�J�J�J�J�J�Js7� AD/�D�D/�D%�"D/�$D%�%	D/�/E�E

?>