Your IP : 3.147.75.217


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

�

^�Dg
C���ddlmZddlZddlZddlZddlZddlmZmZddl	m
Z
mZmZddl
mZmZmZmZddlmZdd	lmZmZdZdZd
Zd
Zd
ZdgZe
eed�Zd
�Zeede��Z 	ddl!Z!ddl!m"Z"m#Z#n#e$$rYnwxYw	ddl!mZn#e$$rYnwxYw	ddl%mZn#e$$rYnwxYw	ddl!m&Z&e&Z'n$#e$$r	ddl!m'Z&e&Z'n#e$$rdxZ'Z&YnwxYwYnwxYw	ddl!m(Z(n
#e$$re&Z(YnwxYw	ddl!m)Z)m*Z*m+Z+n#e$$r
d\Z*Z+dZ)YnwxYw	ddl!m,Z,n
#e$$rdZ,YnwxYwd�-gd���Z.	ddl!mZn#e$$rGd�de/��ZYnwxYwd�Z0d �Z1d!�Z2	d'd"�Z3												d(d#�Z4d$�Z5d%�Z6d)d&�Z7dS)*�)�absolute_importN)�hexlify�	unhexlify)�md5�sha1�sha256�)�InsecurePlatformWarning�ProxySchemeUnsupported�SNIMissingWarning�SSLError)�six�)�BRACELESS_IPV6_ADDRZ_RE�IPV4_REFzhttp/1.1)� �(�@c���tt|��t|��z
��}tt|��t|����D]
\}}|||zz}�|dkS)z�
    Compare two digests of equal length in constant time.

    The digests must be of type str/bytes.
    Returns True if the digests match, and False otherwise.
    r)�abs�len�zip�	bytearray)�a�b�result�left�rights     �H/opt/imunify360/venv/lib64/python3.11/site-packages/urllib3/util/ssl_.py�_const_compare_digest_backportr sd����Q���#�a�&�&��
!�
!�F��9�Q�<�<��1���6�6�����e��$��,�����Q�;���compare_digest)�
CERT_REQUIRED�wrap_socket)�HAS_SNI)�SSLTransport)�PROTOCOL_TLS)�PROTOCOL_SSLv23)�PROTOCOL_TLS_CLIENT)�OP_NO_COMPRESSION�OP_NO_SSLv2�OP_NO_SSLv3)iii)�OP_NO_TICKETi@�:)zECDHE+AESGCMzECDHE+CHACHA20z
DHE+AESGCMzDHE+CHACHA20zECDH+AESGCMz	DH+AESGCMzECDH+AESzDH+AESz
RSA+AESGCMzRSA+AESz!aNULLz!eNULLz!MD5z!DSS)�
SSLContextc�0�eZdZd�Zd�Zdd�Zd�Zd	d�ZdS)
r/c��||_d|_tj|_d|_d|_d|_d|_d|_	dS)NFr)
�protocol�check_hostname�ssl�	CERT_NONE�verify_mode�ca_certs�options�certfile�keyfile�ciphers)�self�protocol_versions  r�__init__zSSLContext.__init__�sB��,�D�M�"'�D��"�}�D�� �D�M��D�L� �D�M��D�L��D�L�L�Lr!c�"�||_||_dS�N)r9r:)r<r9r:s   r�load_cert_chainzSSLContext.load_cert_chain�s��$�D�M�"�D�L�L�Lr!Nc�X�||_|�td���|�td���dS)Nz-CA directories not supported in older Pythonsz&CA data not supported in older Pythons)r7r
)r<�cafile�capath�cadatas    r�load_verify_locationsz SSLContext.load_verify_locations�s;��"�D�M��!��N�O�O�O��!��G�H�H�H�"�!r!c��||_dSr@�r;)r<�cipher_suites  r�set_cipherszSSLContext.set_ciphers�s
��'�D�L�L�Lr!Fc��tjdt��|j|j|j|j|j|d�}t|fd|j	i|��S)Na2A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings)r:r9r7�	cert_reqs�ssl_version�server_sider;)
�warnings�warnr
r:r9r7r6r2r$r;)r<�socket�server_hostnamerN�kwargss     rr$zSSLContext.wrap_socket�sj���M� �(�
�
�
� �<� �M� �M�!�-�#�}�*�
��F��v�F�F�t�|�F�v�F�F�Fr!)NNN)NF)�__name__�
__module__�__qualname__r>rArFrJr$�r!rr/r/�ss������		 �		 �		 �	#�	#�	#�	I�	I�	I�	I�	(�	(�	(�	G�	G�	G�	G�	G�	Gr!r/c���|�dd�����}t|��}t�|��}|s"td�|�����t|�����}||���	��}t||��s0td�|t|�������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.
    r.�z"Fingerprint of invalid length: {0}z6Fingerprints did not match. Expected "{0}", got "{1}".N)�replace�lowerr�HASHFUNC_MAP�getr
�formatr�encode�digest�_const_compare_digestr)�cert�fingerprint�
digest_length�hashfunc�fingerprint_bytes�cert_digests      r�assert_fingerprintrh�s����%�%�c�2�.�.�4�4�6�6�K���$�$�M����
�.�.�H��Q��;�B�B�;�O�O�P�P�P�"�+�"4�"4�"6�"6�7�7���(�4�.�.�'�'�)�)�K� ��.?�@�@�
��D�K�K��W�[�1�1�
�
�
�
�	
�
�
r!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#�
isinstance�str�getattrr4��	candidate�ress  r�resolve_cert_reqsrq�sW�������)�S�!�!���c�9�d�+�+���;��#�w��2�3�3�C��
��r!c��|�tSt|t��r2tt|d��}|�ttd|z��}|S|S)z 
    like resolve_cert_reqs
    N�	PROTOCOL_)r'rkrlrmr4rns  r�resolve_ssl_versionrt�sW�������)�S�!�!���c�9�d�+�+���;��#�{�Y�6�7�7�C��
��r!c�p��|r|tkrt}t|�����|pt��|�t
jn|}|�*d}|tz}|tz}|tz}|tz}�xj|zc_|t
jkstj
dkrt�dd��	�d�_�fd�}|t
jkr|�_|��n|��|�_t#�d��r(t$j�d��}|r|�_�S)	aAll arguments have the same meaning as ``ssl_wrap_socket``.

    By default, this function does a lot of the same work that
    ``ssl.create_default_context`` does on Python 3.4+. It:

    - Disables SSLv2, SSLv3, and compression
    - Sets a restricted set of server ciphers

    If you wish to enable SSLv3, you can do::

        from urllib3.util import ssl_
        context = ssl_.create_urllib3_context()
        context.options &= ~ssl_.OP_NO_SSLv3

    You can do the same to enable compression (substituting ``COMPRESSION``
    for ``SSLv3`` in the last line above).

    :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.
    :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.
    :returns:
        Constructed SSLContext object with specified options
    :rtype: SSLContext
    Nr)����post_handshake_authTc�<��t�dd���	d�_dSdS)Nr3F)rmr3)�contexts�r�disable_check_hostnamez6create_urllib3_context.<locals>.disable_check_hostnameEs/����G�-�t�4�4�@�&+�G�"�"�"�	
A�@r!�keylog_filename�
SSLKEYLOGFILE)r'r)r/rJ�DEFAULT_CIPHERSr4r#r+r,r*r-r8�sys�version_informryr6�hasattr�os�environr]r})rMrLr8r;r|�
sslkeylogfiler{s      @r�create_urllib3_contextr��s{���J�*�+��5�5�)����%�%�G�����2�?�3�3�3�&/�%6��!�!�I�I������;����;���	�$�$��
	�<����O�O�w��O�O�	�S�&�&�&�#�*:�i�*G�*G�W��&��N�N�
�N�'+��#�+�+�+�+�+��C�%�%�%�'����� � � � ��� � � �'����w�)�*�*�4��
����7�7�
��	4�&3�G�#��Nr!c
��|}
|
�t|||���}
|s|	s|rA	|
�||	|��nN#ttf$r}t	|���d}~wwxYw|�$t|
d��r|
���|r |
�t|��rt	d���|r0|
�|
�||��n|
�|||
��	t|
d��r|
�	t��n#t$rYnwxYw|ot|��}|rtpto|}ts|rtjdt"��|rt%||
||���}nt%||
|��}|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.
    NrH�load_default_certsz5Client private key is encrypted, password is required�set_alpn_protocolsa�An HTTPS request has been made, but the SNI (Server Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings�rR)r�rF�IOError�OSErrorr
r�r��_is_key_file_encryptedrAr��ALPN_PROTOCOLS�NotImplementedError�is_ipaddressr%�IS_SECURETRANSPORTrOrPr�_ssl_wrap_socket_impl)�sockr:r9rLr7rRrMr;�ssl_context�ca_cert_dir�key_password�ca_cert_data�
tls_in_tlsr{�e�use_sni_hostname�send_sni�ssl_socks                  r�ssl_wrap_socketr�cs��L�G���)��i��Q�Q�Q���%�;�%�,�%�	��)�)�(�K��N�N�N�N����!�	�	�	��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�
��7�0�1�1�	7��&�&�~�6�6�6����
�
�
���
����
'�L�|�O�/L�/L�+L�� �,�W���.��
��

�'�

��
�
�
�		
�		
�		
��D�(��'�:��
�
�
���)��w�
�C�C���Os'�6�A�A�A�*D�
D�Dc���tjs*t|t��r|�d��}tt
j|��ptj|����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)	r�PY2rk�bytes�decode�boolr�matchr)�hostnames rr�r��sY���7�,�z�(�E�2�2�,��?�?�7�+�+����
�h�'�'�R�+B�+H��+R�+R�S�S�Sr!c��t|d��5}|D]}d|vrddd��dS�	ddd��n#1swxYwYdS)z*Detects if a key file is encrypted or not.�r�	ENCRYPTEDNTF)�open)�key_file�f�lines   rr�r��s���	
�h��	�	����	�	�D��d�"�"��	��������#�	��������������������5s�
6�6�:�:c���|r;tstd���tj|��t|||��S|r|�||���S|�|��S)Nz0TLS in TLS requires support for the 'ssl' moduler�)r&r�$_validate_ssl_context_for_tls_in_tlsr$)r�r�r�rRs    rr�r��s����@��	�(�B���
�	�9�+�F�F�F��D�+��?�?�?��-��&�&�t�_�&�M�M�M��&�&�t�,�,�,r!)NNNN)NNNNNNNNNNNFr@)8�
__future__r�hmacr�r�rO�binasciirr�hashlibrrr�
exceptionsr
rrr
�packagesr�urlrrr/r&r%�IS_PYOPENSSLr�r�r\r rmrar4r#r$�ImportError�ssltransportr'r(r)r*r+r,r-�joinr�objectrhrqrtr�r�r�r�r�rWr!r�<module>r�s���&�&�&�&�&�&�����	�	�	�	�
�
�
�
�����'�'�'�'�'�'�'�'�%�%�%�%�%�%�%�%�%�%�������������������1�1�1�1�1�1�1�1�
�
���
����������T�v�.�.��
�
�
� ���&6�8V�W�W��	��J�J�J�.�.�.�.�.�.�.�.�.���	�	�	��D�	����	����������	�	�	��D�	����	�*�*�*�*�*�*�*���	�	�	��D�	����
+� � � � � � �"�O�O���+�+�+�+�7�7�7�7�7�7�&�����+�+�+�)*�*��,�,�,�+������+����'�'�'�'�'�'�'�'���'�'�'�&����'���� �?�?�?�?�?�?�?�?�?�?�?��� � � �3��K������ ����
� � � � � � � �������L�L�L�����*�(�(�������&2G����������0G�0G�0G�.G�.G�.G�.G�.G�V�.G�.G�.G�.G�.G�0G����f
�
�
�:���.
�
�
�"=A�f�f�f�f�V
�
��
���������c�c�c�c�L
T�
T�
T����-�-�-�-�-�-s��'A4�4A<�;A<�B�B�B�B�B"�!B"�&B/�/C�5B>�=C�>	C
�C�	C
�
C�C�C�C%�$C%�)
C4�4D�D�D�D�D�3D:�:E�E

?>