ó V!¶\c@@s½ddlmZddlZddlZddlZddlZddlmZmZddl m Z m Z m Z ddl mZmZmZddlmZdZeZeZeZie d6e d 6e d 6Zd „Zeed eƒZy<ddlZdd lmZmZm Z ddlmZWne!k r;nXy ddlm"Z"m#Z#m$Z$Wn#e!k rd0\Z"Z#dZ$nXe%edƒrej&Z&n6yddl'Z'd„Z&Wne!k rÒd„Z&nXdj(dddddddddd d!d"d#d$d%d&gƒZ)ydd'lmZWn3e!k r[ddl*Z*d(e+fd)„ƒYZnXd*„Z,d+„Z-d,„Z.ddddd-„Z/dddddddddd.„ Z0d/„Z1dS(1i(tabsolute_importN(thexlifyt unhexlify(tmd5tsha1tsha256i(tSSLErrortInsecurePlatformWarningtSNIMissingWarning(tsixi i(i@cC@s`tt|ƒt|ƒƒ}x7tt|ƒt|ƒƒD]\}}|||AO}q8W|dkS(s§ 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. i(tabstlentzipt bytearray(tatbtresulttltr((s4/tmp/pip-install-usGedi/urllib3/urllib3/util/ssl_.pyt_const_compare_digest_backports(tcompare_digest(t wrap_sockett CERT_NONEtPROTOCOL_SSLv23(tHAS_SNI(t OP_NO_SSLv2t OP_NO_SSLv3tOP_NO_COMPRESSIONiiit inet_ptoncC@s.t|tƒr!|jdƒ}ntj|ƒS(Ntascii(t isinstancetbytestdecodet ipaddresst ip_address(t_thost((s4/tmp/pip-install-usGedi/urllib3/urllib3/util/ssl_.pyRDscC@s tj|ƒS(N(tsockett inet_aton(R#R$((s4/tmp/pip-install-usGedi/urllib3/urllib3/util/ssl_.pyRJst:sTLS13-AES-256-GCM-SHA384sTLS13-CHACHA20-POLY1305-SHA256sTLS13-AES-128-GCM-SHA256s ECDH+AESGCMs ECDH+CHACHA20s DH+AESGCMs DH+CHACHA20s ECDH+AES256s DH+AES256s ECDH+AES128sDH+AESs RSA+AESGCMsRSA+AESs!aNULLs!eNULLs!MD5(t SSLContextR(cB@sAeZd„Zd„Zddd„Zd„Zded„ZRS(cC@sO||_t|_tj|_d|_d|_d|_ d|_ d|_ dS(Ni( tprotocoltFalsetcheck_hostnametsslRt verify_modetNonetca_certstoptionstcertfiletkeyfiletciphers(tselftprotocol_version((s4/tmp/pip-install-usGedi/urllib3/urllib3/util/ssl_.pyt__init__vs       cC@s||_||_dS(N(R1R2(R4R1R2((s4/tmp/pip-install-usGedi/urllib3/urllib3/util/ssl_.pytload_cert_chains cC@s(||_|dk r$tdƒ‚ndS(Ns-CA directories not supported in older Pythons(R/R.R(R4tcafiletcapath((s4/tmp/pip-install-usGedi/urllib3/urllib3/util/ssl_.pytload_verify_locations…s  cC@s ||_dS(N(R3(R4t cipher_suite((s4/tmp/pip-install-usGedi/urllib3/urllib3/util/ssl_.pyt set_ciphers‹scC@setjdtƒi|jd6|jd6|jd6|jd6|jd6|d6}t|d|j |S( Ns2A 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-warningsR2R1R/t cert_reqst ssl_versiont server_sideR3( twarningstwarnRR2R1R/R-R)RR3(R4R%tserver_hostnameR?tkwargs((s4/tmp/pip-install-usGedi/urllib3/urllib3/util/ssl_.pyRŽs      N( t__name__t __module__R6R7R.R:R<R*R(((s4/tmp/pip-install-usGedi/urllib3/urllib3/util/ssl_.pyR(us   cC@s©|jddƒjƒ}t|ƒ}tj|ƒ}|sQtdj|ƒƒ‚nt|jƒƒ}||ƒj ƒ}t ||ƒs¥tdj|t |ƒƒƒ‚ndS(sá 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'ts"Fingerprint of invalid length: {0}s6Fingerprints did not match. Expected "{0}", got "{1}".N( treplacetlowerR t HASHFUNC_MAPtgetRtformatRtencodetdigestt_const_compare_digestR(tcertt fingerprintt digest_lengththashfunctfingerprint_bytest cert_digest((s4/tmp/pip-install-usGedi/urllib3/urllib3/util/ssl_.pytassert_fingerprint£s   cC@s[|dkrtSt|tƒrWtt|dƒ}|dkrSttd|ƒ}n|S|S(sç 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_NONE`. 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. tCERT_N(R.RRtstrtgetattrR,(t candidatetres((s4/tmp/pip-install-usGedi/urllib3/urllib3/util/ssl_.pytresolve_cert_reqs¾s  cC@s[|dkrtSt|tƒrWtt|dƒ}|dkrSttd|ƒ}n|S|S(s like resolve_cert_reqs t PROTOCOL_N(R.RRRWRXR,(RYRZ((s4/tmp/pip-install-usGedi/urllib3/urllib3/util/ssl_.pytresolve_ssl_versionÕs  cC@s¶t|ptjƒ}|j|p$tƒ|dkr=tjn|}|dkrvd}|tO}|tO}|t O}n|j |O_ ||_ t |ddƒdk r²t |_n|S(sëAll 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``. :param ciphers: Which cipher suites to allow the server to select. :returns: Constructed SSLContext object with specified options :rtype: SSLContext iR+N(R(R,RR<tDEFAULT_CIPHERSR.t CERT_REQUIREDRRRR0R-RXR*R+(R>R=R0R3tcontext((s4/tmp/pip-install-usGedi/urllib3/urllib3/util/ssl_.pytcreate_urllib3_contextås#      c C@sG|} | dkr*t||d|ƒ} n|s6| r¥y| j|| ƒWqÊtk rk} t| ƒ‚qÊtk r¡} | jtjkr›t| ƒ‚n‚qÊXn%t| ddƒdk rÊ| j ƒn|rã| j ||ƒn|dk rüt |ƒ st r:t r'|dk r'| j|d|ƒStjdtƒn| j|ƒS(sà 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(). R3tload_default_certsRBs€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-warningsN(R.RaR:tIOErrorRtOSErrorterrnotENOENTRXRbR7t is_ipaddresstIS_SECURETRANSPORTRRR@RAR( tsockR2R1R=R/RBR>R3t ssl_contextt ca_cert_dirR`te((s4/tmp/pip-install-usGedi/urllib3/urllib3/util/ssl_.pytssl_wrap_socket#s2       cC@s¢tjr*t|tƒr*|jdƒ}ntjg}ttdƒrX|jtj ƒnxC|D];}yt ||ƒWntj t t fk r•q_XtSq_WtS(s­Detects whether the hostname given is an IP address. :param str hostname: Hostname to examine. :return: True if the hostname is an IP address, False otherwise. RtAF_INET6(R tPY3RRR R%tAF_INETthasattrtappendRnRterrort ValueErrorRdtTrueR*(thostnametfamiliestaf((s4/tmp/pip-install-usGedi/urllib3/urllib3/util/ssl_.pyRghs  (ii(2t __future__RReR@thmacR%tbinasciiRRthashlibRRRt exceptionsRRRtpackagesR R.R(R*Rt IS_PYOPENSSLRhRIRRXRNR,RRRt ImportErrorRRRRqRR!tjoinR^tsystobjectRUR[R]RaRmRg(((s4/tmp/pip-install-usGedi/urllib3/urllib3/util/ssl_.pytsŠ                     .   =   B