Hacked By AnonymousFox

Current Path : /opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyc

�
�Rec@@s%dZddlmZddlZddlmZddlmZ	ddl
mZyddlm
Z
Wn'ek
r�defd	��YZ
nXdd
lmZmZddlmZyddlmZWn'ek
r�dZd
dlmZnXddlZddlZd
dlmZddlZd
dlm Z ddgZ!e"Z#iej$j%e j&6ej$j'ej(6Z)e*ed�r�e*ej$d�r�ej$j+e)ej,<ne*ed�r�e*ej$d�r�ej$j-e)ej.<ne*ed�re*ej$d�rej$j/e)ej0<niej$j1ej26ej$j3ej46ej$j3ej$j5ej66Z7e8d�e7j9�D��Z:dZ;e j#Z<e j=j>Z?ej@eA�ZBd�ZCd�ZDd�ZEd�ZFd�ZGd eHfd!��YZIer�d"d#�ZJneZJeJeI_Jd$eHfd%��YZKd&�ZLdS('sb
SSL with SNI_-support for Python 2. Follow these instructions if you would
like to verify SSL certificates in Python 2. Note, the default libraries do
*not* do certificate checking; you need to do additional work to validate
certificates yourself.

This needs the following packages installed:

* pyOpenSSL (tested with 16.0.0)
* cryptography (minimum 1.3.4, from pyopenssl)
* idna (minimum 2.0, from cryptography)

However, pyopenssl depends on cryptography, which depends on idna, so while we
use all three directly here we end up having relatively few packages required.

You can install them with the following command:

    pip install pyopenssl cryptography idna

To activate certificate checking, call
:func:`~urllib3.contrib.pyopenssl.inject_into_urllib3` from your Python code
before you begin making HTTP requests. This can be done in a ``sitecustomize``
module, or at any other time before your application begins using ``urllib3``,
like this::

    try:
        import urllib3.contrib.pyopenssl
        urllib3.contrib.pyopenssl.inject_into_urllib3()
    except ImportError:
        pass

Now you can use :mod:`urllib3` as you normally would, and it will support SNI
when the required modules are installed.

Activating this module also has the positive side effect of disabling SSL/TLS
compression in Python 2 (see `CRIME attack`_).

If you want to configure the default list of supported cipher suites, you can
set the ``urllib3.contrib.pyopenssl.DEFAULT_SSL_CIPHER_LIST`` variable.

.. _sni: https://en.wikipedia.org/wiki/Server_Name_Indication
.. _crime attack: https://en.wikipedia.org/wiki/CRIME_(security_exploit)
i(tabsolute_importN(tx509(tbackend(t_Certificate(tUnsupportedExtensionRcB@seZRS((t__name__t
__module__(((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR7s(ttimeoutterror(tBytesIO(t_fileobjecti(tbackport_makefile(tsix(tutiltinject_into_urllib3textract_from_urllib3tPROTOCOL_SSLv3tSSLv3_METHODtPROTOCOL_TLSv1_1tTLSv1_1_METHODtPROTOCOL_TLSv1_2tTLSv1_2_METHODcc@s!|]\}}||fVqdS(N((t.0tktv((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pys	<genexpr>gsi@cC@sJt�tt_ttj_tt_ttj_tt_ttj_dS(s7Monkey-patch urllib3 with PyOpenSSL-backed SSL-support.N(t_validate_dependencies_mettPyOpenSSLContextR
t
SSLContexttssl_tHAS_SNItTruetIS_PYOPENSSL(((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyRss			cC@sCtt_ttj_tt_ttj_tt_ttj_dS(s4Undo monkey-patching by :func:`inject_into_urllib3`.N(torig_util_SSLContextR
RRtorig_util_HAS_SNIRtFalseR(((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR�s			cC@s{ddlm}t|dd�dkr7td��nddlm}|�}t|dd�dkrwtd��ndS(	s{
    Verifies that PyOpenSSL's package-level dependencies have been met.
    Throws `ImportError` if they are not met.
    i(t
Extensionstget_extension_for_classsX'cryptography' module missing required functionality.  Try upgrading to v1.3.4 or newer.(tX509t_x509sS'pyOpenSSL' module missing required functionality. Try upgrading to v0.14 or newer.N(tcryptography.x509.extensionsR#tgetattrtNonetImportErrortOpenSSL.cryptoR%(R#R%R((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR�s	cC@sZd�}d|kr|S||�}|dkr5dStjdkrV|jd�}n|S(s%
    Converts a dNSName SubjectAlternativeName field to the form used by the
    standard library on the given Python version.

    Cryptography produces a dNSName as a unicode string that was idna-decoded
    from ASCII bytes. We need to idna-encode that string to get it back, and
    then on Python 3 we also need to convert to unicode via UTF-8 (the stdlib
    uses PyUnicode_FromStringAndSize on it, which decodes via UTF-8).

    If the name cannot be idna-encoded then we return None signalling that
    the name given should be skipped.
    cS@s�ddlm}yaxMddgD]?}|j|�r |t|�}|jd�|j|�Sq W|j|�SWn|jjk
r�dSXdS(s�
        Borrowed wholesale from the Python Cryptography Project. It turns out
        that we can't just safely call `idna.encode`: it can explode for
        wildcard names. This avoids that problem.
        i(tidnau*.u.tasciiN(tpip._vendorR,t
startswithtlentencodetcoret	IDNAErrorR)(tnameR,tprefix((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pytidna_encode�st:iisutf-8N(ii(R)tsystversion_infotdecode(R4R6((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt_dnsname_to_stdlib�s	cC@st|d�r|j�}ntt|j�}y|jjtj�j	}WnJtj
k
rcgStjttj
tfk
r�}tjd|�gSXgtt|jtj��D]}|dk	r�d|f^q�}|jd�|jtj�D��|S(sU
    Given an PyOpenSSL certificate, provides all the subject alternative names.
    tto_cryptographys�A problem was encountered with the certificate that prevented urllib3 from finding the SubjectAlternativeName field. This can affect certificate validation. The error was %stDNScs@s!|]}dt|�fVqdS(s
IP AddressN(tstr(RR4((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pys	<genexpr>sN(thasattrR<Rtopenssl_backendR&t
extensionsR$RtSubjectAlternativeNametvaluetExtensionNotFoundtDuplicateExtensionRtUnsupportedGeneralNameTypetUnicodeErrortlogtwarningtmapR;tget_values_for_typetDNSNameR)textendt	IPAddress(t	peer_certtcerttextteR4tnames((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pytget_subj_alt_name�s.

t
WrappedSocketcB@s�eZdZed�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
ed�Zd�Zd
�Zd�ZRS(s�API-compatibility wrapper for Python OpenSSL's Connection-class.

    Note: _makefile_refs, _drop() and _reuse() are needed for the garbage
    collector of pypy.
    cC@s1||_||_||_d|_t|_dS(Ni(t
connectiontsockettsuppress_ragged_eofst_makefile_refsR"t_closed(tselfRVRWRX((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt__init__
s
				cC@s
|jj�S(N(RWtfileno(R[((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR]scC@s;|jdkr!|jd8_n|jr7|j�ndS(Nii(RYRZtclose(R[((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt_decref_socketioss	cO@s!y|jj||�}Wn�tjjk
rb}|jrM|jdkrMdStt|���n�tjj	k
r�|jj
�tjjkr�dS�n�tjjk
r�t
j|j|jj��s�td��q|j||�Sn0tjjk
r}tjd|��nX|SdS(Ni����sUnexpected EOFtsThe read operation timed outsread error: %r(i����sUnexpected EOF(RVtrecvtOpenSSLtSSLtSysCallErrorRXtargstSocketErrorR>tZeroReturnErrortget_shutdowntRECEIVED_SHUTDOWNt
WantReadErrorR
t
wait_for_readRWt
gettimeoutRtErrortssltSSLError(R[RetkwargstdataRR((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyRas"cO@sy|jj||�SWn�tjjk
r`}|jrK|jdkrKdStt|���n�tjj	k
r�|jj
�tjjkr�dS�ntjjk
r�t
j|j|jj��s�td��q|j||�Sn,tjjk
r}tjd|��nXdS(Ni����sUnexpected EOFisThe read operation timed outsread error: %r(i����sUnexpected EOF(RVt	recv_intoRbRcRdRXReRfR>RgRhRiRjR
RkRWRlRRmRnRo(R[ReRpRR((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyRr7s cC@s|jj|�S(N(RWt
settimeout(R[R((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyRsNscC@s�x�tr�y|jj|�SWqtjjk
rctj|j|jj	��st
��qqqtjjk
r�}tt
|���qXqWdS(N(RRVtsendRbRctWantWriteErrorR
twait_for_writeRWRlRRdRfR>(R[RqRR((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt_send_until_doneQs	cC@sGd}x:|t|�krB|j|||t!�}||7}q	WdS(Ni(R0RwtSSL_WRITE_BLOCKSIZE(R[Rqt
total_senttsent((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pytsendall\s
cC@s|jj�dS(N(RVtshutdown(R[((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR|dscC@sZ|jdkrGyt|_|jj�SWqVtjjk
rCdSXn|jd8_dS(Ni(RYRRZRVR^RbRcRm(R[((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR^hs	cC@se|jj�}|s|S|r8tjjtjj|�Sid|j�jfffd6t|�d6S(Nt
commonNametsubjecttsubjectAltName(	RVtget_peer_certificateRbtcryptotdump_certificatet
FILETYPE_ASN1tget_subjecttCNRT(R[tbinary_formR((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pytgetpeercertrscC@s
|jj�S(N(RVtget_protocol_version_name(R[((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pytversion�scC@s|jd7_dS(Ni(RY(R[((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt_reuse�scC@s/|jdkr|j�n|jd8_dS(Ni(RYR^(R[((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt_drop�s
(RRt__doc__RR\R]R_RaRrRsRwR{R|R^R"R�R�R�R�(((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyRUs									
		i����cC@s%|jd7_t|||dt�S(NiR^(RYR
R(R[tmodetbufsize((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pytmakefile�sRcB@s�eZdZd�Zed��Zejd��Zed��Zejd��Zd�Zd�Z	dddd�Zddd	�Ze
eedd
�ZRS(s�
    I am a wrapper class for the PyOpenSSL ``Context`` object. I am responsible
    for translating the interface of the standard library ``SSLContext`` object
    to calls into PyOpenSSL.
    cC@s;t||_tjj|j�|_d|_t|_dS(Ni(	t_openssl_versionstprotocolRbRctContextt_ctxt_optionsR"tcheck_hostname(R[R�((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR\�s
	cC@s|jS(N(R�(R[((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pytoptions�scC@s||_|jj|�dS(N(R�R�tset_options(R[RC((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR��s	cC@st|jj�S(N(t_openssl_to_stdlib_verifyR�tget_verify_mode(R[((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pytverify_mode�scC@s|jjt|t�dS(N(R�t
set_verifyt_stdlib_to_openssl_verifyt_verify_callback(R[RC((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR��scC@s|jj�dS(N(R�tset_default_verify_paths(R[((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR��scC@s8t|tj�r$|jd�}n|jj|�dS(Nsutf-8(t
isinstanceRt	text_typeR1R�tset_cipher_list(R[tciphers((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pytset_ciphers�scC@s�|dk	r|jd�}n|dk	r<|jd�}ny<|jj||�|dk	rw|jjt|��nWn,tjjk
r�}tj	d|��nXdS(Nsutf-8s'unable to load trusted certificates: %r(
R)R1R�tload_verify_locationsR	RbRcRmRnRo(R[tcafiletcapathtcadataRR((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR��sc@sv|jj|��dk	r\t�tj�s@�jd��n|jj�fd��n|jj|pn|�dS(Nsutf-8c@s�S(N((t_(tpassword(s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt<lambda>�R`(	R�tuse_certificate_chain_fileR)R�Rtbinary_typeR1t
set_passwd_cbtuse_privatekey_file(R[tcertfiletkeyfileR�((R�s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pytload_cert_chain�scC@s�tjj|j|�}t|tj�r<|jd�}n|dk	rX|j	|�n|j
�x�tr�y|j�Wnltjj
k
r�tj||j��setd��qeqen,tjjk
r�}tjd|��nXPqeWt||�S(Nsutf-8sselect timed outsbad handshake: %r(RbRct
ConnectionR�R�RR�R1R)tset_tlsext_host_nametset_connect_stateRtdo_handshakeRjR
RkRlRRmRnRoRU(R[tsocktserver_sidetdo_handshake_on_connectRXtserver_hostnametcnxRR((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pytwrap_socket�s"
	N(RRR�R\tpropertyR�tsetterR�R�R�R)R�R�R"RR�(((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR�s			cC@s
|dkS(Ni((R�Rterr_not	err_depthtreturn_code((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR��s(MR�t
__future__RtOpenSSL.SSLRbtcryptographyRt$cryptography.hazmat.backends.opensslRR@t)cryptography.hazmat.backends.openssl.x509Rtcryptography.x509RR*t	ExceptionRWRRRftioR	R
R)tpackages.backports.makefileRtloggingRntpackagesRR8R`R
t__all__RRRct
SSLv23_METHODtPROTOCOL_TLStTLSv1_METHODtPROTOCOL_TLSv1R�R?RRRRRRtVERIFY_NONEt	CERT_NONEtVERIFY_PEERt
CERT_OPTIONALtVERIFY_FAIL_IF_NO_PEER_CERTt
CERT_REQUIREDR�tdicttitemsR�RxR!RRR t	getLoggerRRHRRRR;RTtobjectRUR�RR�(((s�/builddir/build/BUILDROOT/alt-python27-pip-20.2.4-5.el8.x86_64/opt/alt/python27/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt<module>+sl

!!!			
			+	6�	Z

Hacked By AnonymousFox1.0, Coded By AnonymousFox