uawdijnntqw1x1x1
IP : 3.15.229.217
Hostname : host45.registrar-servers.com
Kernel : Linux host45.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64
Disable Function : None :)
OS : Linux
PATH:
/
home
/
..
/
lib
/
python3.6
/
site-packages
/
urllib3
/
contrib
/
__pycache__
/
pyopenssl.cpython-36.opt-1.pyc
/
/
3 nf�\�=�@sddZddlmZddlZddlmZddlmZ ddl mZyddlm Z Wn$ek rpGdd �d e�Z YnXdd lmZmZddlmZyddlmZWn$ek r�dZd dlmZYnXddlZddlZd dlmZddlZd dlmZddgZ dZ!ej"ej#j$ej%ej#j&iZ'e(ed��r@e(ej#d��r@ej#j)e'ej*<e(ed��rhe(ej#d��rhej#j+e'ej,<ye'j-ej.ej#j/i�Wne0k �r�YnXej1ej#j2ej3ej#j4ej5ej#j4ej#j6iZ7e8dd�e7j9�D��Z:dZ;ej!Z<ej=j>Z?ej@eA�ZBdd�ZCdd�ZDdd�ZEdd �ZFd!d"�ZGGd#d$�d$eH�ZIe�r>d-d&d'�ZJneZJeJeI_JGd(d)�d)eH�ZKd*d+�ZLdS).ab 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) �)�absolute_importN)�x509)�backend)�_Certificate)�UnsupportedExtensionc@seZdZdS)rN)�__name__� __module__�__qualname__�r r �/usr/lib/python3.6/pyopenssl.pyr6sr)�timeout�error)�BytesIO)�_fileobject�)�backport_makefile)�six)�util�inject_into_urllib3�extract_from_urllib3T�PROTOCOL_TLSv1_1�TLSv1_1_METHOD�PROTOCOL_TLSv1_2�TLSv1_2_METHODccs|]\}}||fVqdS)Nr )�.0�k�vr r r� <genexpr>fsri@cCs.t�ttj_tt_ttj_dt_dtj_dS)z7Monkey-patch urllib3 with PyOpenSSL-backed SSL-support.TN)�_validate_dependencies_met�PyOpenSSLContextr�ssl_� SSLContext�HAS_SNI�IS_PYOPENSSLr r r rrsscCs(ttj_tt_ttj_dt_dtj_dS)z4Undo monkey-patching by :func:`inject_into_urllib3`.FN)�orig_util_SSLContextrr r!�orig_util_HAS_SNIr"r#r r r rrs cCsRddlm}t|dd�dkr$td��ddlm}|�}t|dd�dkrNtd��dS) z{ Verifies that PyOpenSSL's package-level dependencies have been met. Throws `ImportError` if they are not met. r)� Extensions�get_extension_for_classNzX'cryptography' module missing required functionality. Try upgrading to v1.3.4 or newer.)�X509�_x509zS'pyOpenSSL' module missing required functionality. Try upgrading to v0.14 or newer.)Zcryptography.x509.extensionsr&�getattr�ImportErrorZOpenSSL.cryptor()r&r(rr r rr�srcCs@dd�}d|kr|S||�}|dkr(dStjdkr<|jd�}|S) a% 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. cSslddl}yFx:dD]2}|j|�r|t|�d�}|jd�|j|�SqW|j|�S|jjk rfdSXdS)z� 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. rN�*.�.�ascii)r,r-)�idna� startswith�len�encodeZcoreZ IDNAError)�namer/�prefixr r r�idna_encode�s z'_dnsname_to_stdlib.<locals>.idna_encode�:N�rzutf-8)r7r)�sys�version_info�decode)r3r5r r r�_dnsname_to_stdlib�s r;cCs�t|d�r|j�}ntt|j�}y|jjtj�j }WnLtj k rJgStjttj tfk r�}ztjd|�gSd}~XnXdd�tt|jtj��D�}|jdd�|jtj�D��|S)zU Given an PyOpenSSL certificate, provides all the subject alternative names. �to_cryptographyz�A problem was encountered with the certificate that prevented urllib3 from finding the SubjectAlternativeName field. This can affect certificate validation. The error was %sNcSsg|]}|dk rd|f�qS)NZDNSr )rr3r r r� <listcomp>�sz%get_subj_alt_name.<locals>.<listcomp>css|]}dt|�fVqdS)z IP AddressN)�str)rr3r r rr�sz$get_subj_alt_name.<locals>.<genexpr>)�hasattrr<r�openssl_backendr)� extensionsr'rZSubjectAlternativeName�valueZExtensionNotFoundZDuplicateExtensionrZUnsupportedGeneralNameType�UnicodeError�logZwarning�mapr;Zget_values_for_typeZDNSName�extendZ IPAddress)Z peer_certZcertZext�e�namesr r r�get_subj_alt_name�s& rIc@s|eZdZdZddd�Zdd�Zdd�Zd d �Zdd�Zd d�Z dd�Z dd�Zdd�Zdd�Z d dd�Zdd�Zdd�ZdS)!� WrappedSocketz�API-compatibility wrapper for Python OpenSSL's Connection-class. Note: _makefile_refs, _drop() and _reuse() are needed for the garbage collector of pypy. TcCs"||_||_||_d|_d|_dS)NrF)� connection�socket�suppress_ragged_eofs�_makefile_refs�_closed)�selfrKrLrMr r r�__init__s zWrappedSocket.__init__cCs |jj�S)N)rL�fileno)rPr r rrRszWrappedSocket.filenocCs*|jdkr|jd8_|jr&|j�dS)Nr�)rNrO�close)rPr r r�_decref_socketioss zWrappedSocket._decref_socketioscOs�y|jj||�}Wn�tjjk rX}z&|jr<|jdkr<dStt|���WYdd}~Xn�tjj k r�}z|jj �tjjkr�dS�WYdd}~XnFtjjk r�t j|j|jj��s�td��n|j||�SYnX|SdS)NrS�Unexpected EOF�zThe read operation timed out���)rXrV)rK�recv�OpenSSL�SSL�SysCallErrorrM�args�SocketErrorr>�ZeroReturnError�get_shutdown�RECEIVED_SHUTDOWN� WantReadErrorr� wait_for_readrL� gettimeoutr)rPr]�kwargs�datarGr r rrYs zWrappedSocket.recvcOs�y|jj||�Stjjk rT}z&|jr8|jdkr8dStt|���WYdd}~Xn~tjj k r�}z|jj �tjjkr~dS�WYdd}~XnBtjjk r�t j|j|jj��s�td��n|j||�SYnXdS)NrS�Unexpected EOFrzThe read operation timed outrX)rXrg)rK� recv_intorZr[r\rMr]r^r>r_r`rarbrrcrLrdr)rPr]rerGr r rrh's zWrappedSocket.recv_intocCs|jj|�S)N)rL� settimeout)rPrr r rri:szWrappedSocket.settimeoutcCs|xvy|jj|�Stjjk rBtj|j|jj��s<t ��wYqtjj k rr}ztt|���WYdd}~XqXqWdS)N) rK�sendrZr[ZWantWriteErrorrZwait_for_writerLrdrr\r^r>)rPrfrGr r r�_send_until_done=szWrappedSocket._send_until_donecCs8d}x.|t|�kr2|j|||t��}||7}qWdS)Nr)r1rk�SSL_WRITE_BLOCKSIZE)rPrfZ total_sentZsentr r r�sendallHszWrappedSocket.sendallcCs|jj�dS)N)rK�shutdown)rPr r rrnNszWrappedSocket.shutdowncCsH|jdkr6yd|_|jj�Stjjk r2dSXn|jd8_dS)NrST)rNrOrKrTrZr[�Error)rPr r rrTRs zWrappedSocket.closeFcCsD|jj�}|s|S|r(tjjtjj|�Sd|j�jffft|�d�S)NZ commonName)ZsubjectZsubjectAltName) rKZget_peer_certificaterZZcryptoZdump_certificateZ FILETYPE_ASN1Zget_subjectZCNrI)rPZbinary_formrr r r�getpeercert\s zWrappedSocket.getpeercertcCs|jd7_dS)NrS)rN)rPr r r�_reusenszWrappedSocket._reusecCs&|jdkr|j�n|jd8_dS)NrS)rNrT)rPr r r�_dropqs zWrappedSocket._dropN)T)F)rrr �__doc__rQrRrUrYrhrirkrmrnrTrprqrrr r r rrJ�s rJrScCs|jd7_t|||dd�S)NrST)rT)rNr)rP�mode�bufsizer r r�makefileysrvc@szeZdZdZdd�Zedd��Zejdd��Zedd��Zejd d��Zd d�Z dd �Z ddd�Zddd�Zddd�Z dS)rz� 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. cCs*t||_tjj|j�|_d|_d|_dS)NrF)�_openssl_versions�protocolrZr[ZContext�_ctx�_optionsZcheck_hostname)rPrxr r rrQ�s zPyOpenSSLContext.__init__cCs|jS)N)rz)rPr r r�options�szPyOpenSSLContext.optionscCs||_|jj|�dS)N)rzryZset_options)rPrBr r rr{�scCst|jj�S)N)�_openssl_to_stdlib_verifyryZget_verify_mode)rPr r r�verify_mode�szPyOpenSSLContext.verify_modecCs|jjt|t�dS)N)ryZ set_verify�_stdlib_to_openssl_verify�_verify_callback)rPrBr r rr}�scCs|jj�dS)N)ry�set_default_verify_paths)rPr r rr��sz)PyOpenSSLContext.set_default_verify_pathscCs&t|tj�r|jd�}|jj|�dS)Nzutf-8)� isinstancer� text_typer2ryZset_cipher_list)rPZciphersr r r�set_ciphers�s zPyOpenSSLContext.set_ciphersNcCsN|dk r|jd�}|dk r$|jd�}|jj||�|dk rJ|jjt|��dS)Nzutf-8)r2ry�load_verify_locationsr)rPZcafileZcapathZcadatar r rr��s z&PyOpenSSLContext.load_verify_locationscs<|jj|��dk r(|jj�fdd��|jj|p4|�dS)Ncs�S)Nr )Z max_lengthZprompt_twiceZuserdata)�passwordr r�<lambda>�sz2PyOpenSSLContext.load_cert_chain.<locals>.<lambda>)ryZuse_certificate_chain_fileZ set_passwd_cbZuse_privatekey_file)rPZcertfileZkeyfiler�r )r�r�load_cert_chain�sz PyOpenSSLContext.load_cert_chainFTcCs�tjj|j|�}t|tj�r&|jd�}|dk r8|j|�|j �xxy|j �Wndtjjk r�tj ||j��sztd��wBYn4tjjk r�}ztjd|��WYdd}~XnXPqBWt||�S)Nzutf-8zselect timed outzbad handshake: %r)rZr[Z Connectionryr�rr�r2Zset_tlsext_host_nameZset_connect_stateZdo_handshakerbrrcrdrro�sslZSSLErrorrJ)rPZsockZserver_sideZdo_handshake_on_connectrMZserver_hostname�cnxrGr r r�wrap_socket�s" zPyOpenSSLContext.wrap_socket)NNN)NN)FTTN)rrr rsrQ�propertyr{�setterr}r�r�r�r�r�r r r rr�s rcCs|dkS)Nrr )r�rZerr_noZ err_depthZreturn_coder r rr�srrX)rX)MrsZ __future__rZOpenSSL.SSLrZZcryptographyrZ$cryptography.hazmat.backends.opensslrr@Z)cryptography.hazmat.backends.openssl.x509rZcryptography.x509rr+� ExceptionrLrr r^�iorrZpackages.backports.makefilerZloggingr�Zpackagesrr8�r�__all__r"ZPROTOCOL_SSLv23r[Z SSLv23_METHODZPROTOCOL_TLSv1ZTLSv1_METHODrwr?rrrr�updateZPROTOCOL_SSLv3ZSSLv3_METHOD�AttributeErrorZ CERT_NONEZVERIFY_NONEZ CERT_OPTIONALZVERIFY_PEERZ CERT_REQUIREDZVERIFY_FAIL_IF_NO_PEER_CERTr~�dict�itemsr|rlr%r r!r$Z getLoggerrrDrrrr;rI�objectrJrvrrr r r r�<module>+sn )4~R
/home/../lib/python3.6/site-packages/urllib3/contrib/__pycache__/pyopenssl.cpython-36.opt-1.pyc