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