U ��.eS7�@s(ddlmZddlZddlZddlZddlZddlmZmZddl m Z m Z m Z ddl mZmZddlmZmZmZdd lmZdZd Zd Zd Ze e e d �Zd d �Zeede�Zz(ddlZddlmZm Z ddlmZWne!k r�YnXzddlm"Z"e"Z#WnJe!k �rLzddlm#Z"e"Z#Wne!k �rFdZ#Z"YnXYnXzddlm$Z$m%Z%m&Z&Wn"e!k �r�d\Z$Z%dZ&YnXd�'dddddddddd d!d"d#d$g�Z(zdd%lmZWn&e!k �r�Gd&d'�d'e)�ZYnXd(d)�Z*d*d+�Z+d,d-�Z,d6d.d/�Z-d7d0d1�Z.d2d3�Z/d4d5�Z0dS)8�)�absolute_importN)�hexlify� unhexlify)�md5�sha1�sha256�)�IPV4_RE�BRACELESS_IPV6_ADDRZ_RE�)�SSLError�InsecurePlatformWarning�SNIMissingWarning)�sixF)� �(�@cCsDtt|�t|��}tt|�t|��D]\}}|||AO}q&|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�l�r�r�A/usr/lib/python3.8/site-packages/pip/_vendor/urllib3/util/ssl_.py�_const_compare_digest_backportsrZcompare_digest)� wrap_socket� CERT_REQUIRED)�HAS_SNI)� PROTOCOL_TLS)�PROTOCOL_SSLv23)� OP_NO_SSLv2� OP_NO_SSLv3�OP_NO_COMPRESSION)iii�:z ECDHE+AESGCMzECDHE+CHACHA20z DHE+AESGCMz DHE+CHACHA20z ECDH+AESGCMz DH+AESGCMzECDH+AESzDH+AESz RSA+AESGCMzRSA+AESz!aNULLz!eNULLz!MD5z!DSS)� SSLContextc@s8eZdZdd�Zdd�Zd dd�Zdd �Zdd d �ZdS)r(cCs6||_d|_tj|_d|_d|_d|_d|_d|_ dS)NFr) �protocol�check_hostname�sslZ CERT_NONE� verify_mode�ca_certs�options�certfile�keyfile�ciphers)�selfZprotocol_versionrrr�__init__kszSSLContext.__init__cCs||_||_dS�N)r/r0)r2r/r0rrr�load_cert_chainvszSSLContext.load_cert_chainNcCs||_|dk rtd��dS)Nz-CA directories not supported in older Pythons)r-r )r2ZcafileZcapathrrr�load_verify_locationszsz SSLContext.load_verify_locationscCs ||_dSr4�r1)r2Z cipher_suiterrr� set_ciphers�szSSLContext.set_ciphersFcCs>t�dt�|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/latest/advanced-usage.html#ssl-warnings)r0r/r-� cert_reqs� ssl_version� server_sider1) �warnings�warnr r0r/r-r,r)rr1)r2Zsocket�server_hostnamer;�kwargsrrrr�s� �zSSLContext.wrap_socket)NN)NF)�__name__� __module__� __qualname__r3r5r6r8rrrrrr(js   r(cCsn|�dd���}t|�}t�|�}|s4td�|���t|���}||�� �}t ||�sjtd�|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�encodeZdigest�_const_compare_digestr)ZcertZ fingerprintZ digest_lengthZhashfuncZfingerprint_bytesZ cert_digestrrr�assert_fingerprint�s     ��rKcCs@|dkr tSt|t�ra�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/latest/advanced-usage.html#ssl-warnings)r\r6�IOErrorr �OSError�errnoZENOENT�hasattrr]�_is_key_file_encryptedr5� is_ipaddress�IS_SECURETRANSPORTr!rr<r=r) Zsockr0r/r9r-r>r:r1Z ssl_contextZ ca_cert_dirZ key_passwordr[�errr�ssl_wrap_socket(sB ���� rfcCs2tjst|t�r|�d�}tt�|�p.t�|��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) rZPY2rL�bytes�decode�boolr �matchr )Zhostnamerrrrc�s rcc Cs<t|d��(}|D]}d|krW5QR�dSqW5QRXdS)z*Detects if a key file is encrypted or not.rZ ENCRYPTEDTF)�open)Zkey_file�f�linerrrrb�s  rb)NNNN) NNNNNNNNNN)1Z __future__rr`r<ZhmacrYZbinasciirrZhashlibrrrZurlr r � exceptionsr r rZpackagesrr(r!Z IS_PYOPENSSLrdrFrrNrJr+rr � ImportErrorr"r#r$r%r&�joinrX�objectrKrRrSr\rfrcrbrrrr�s�       ��.� N� Z