Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/urllib3/contrib/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/urllib3/contrib/__pycache__/pyopenssl.cpython-310.pyc
o

�g�A�@sddZddlmZddlZddlmZddlmZ	ddl
mZzddlm
Z
Wney7Gdd	�d	e�Z
Ynwdd
lmZddlmZddlmZzdd
lmZWneycdZddlmZYnwddlZddlZddlZddlmZddlZddlm Z ddgZ!dZ"ej#ej$j%e ej$j%ej&ej$j'iZ(e)ed�r�e)ej$d�r�ej$j*e(ej+<e)ed�r�e)ej$d�r�ej$j,e(ej-<e)ed�r�e)ej$d�r�ej$j.e(ej/<ej0ej$j1ej2ej$j3ej4ej$j3ej$j5iZ6e7dd�e6�8�D��Z9dZ:ej"Z;ej<j=Z>e�?e@�ZAdd�ZBdd�ZCd d!�ZDd"d#�ZEd$d%�ZFGd&d'�d'eG�ZHe�rd/d)d*�ZIneZIeIeH_IGd+d,�d,eG�ZJd-d.�ZKdS)0a�
TLS with SNI_-support for Python 2. Follow these instructions if you would
like to verify TLS 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:

.. code-block:: bash

    $ python -m 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:

.. code-block:: python

    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`_).

.. _sni: https://en.wikipedia.org/wiki/Server_Name_Indication
.. _crime attack: https://en.wikipedia.org/wiki/CRIME_(security_exploit)
.. _pyopenssl: https://www.pyopenssl.org
.. _cryptography: https://cryptography.io
.. _idna: https://github.com/kjd/idna
�)�absolute_importN)�x509)�backend)�_Certificate)�UnsupportedExtensionc@seZdZdS)rN)�__name__�
__module__�__qualname__�r
r
�;/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.pyr;sr)�BytesIO)�error)�timeout)�_fileobject�)�backport_makefile)�util)�PROTOCOL_TLS_CLIENT�inject_into_urllib3�extract_from_urllib3T�PROTOCOL_SSLv3�SSLv3_METHOD�PROTOCOL_TLSv1_1�TLSv1_1_METHOD�PROTOCOL_TLSv1_2�TLSv1_2_METHODccs�|]	\}}||fVqdS�Nr
)�.0�k�vr
r
r�	<genexpr>ms�r i@cCs4t�tt_ttj_tt_ttj_dt_dtj_dS)z7Monkey-patch urllib3 with PyOpenSSL-backed SSL-support.TN)�_validate_dependencies_met�PyOpenSSLContextr�
SSLContext�ssl_�HAS_SNI�IS_PYOPENSSLr
r
r
rryscCs.tt_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
rr�scCsRddlm}t|dd�durtd��ddlm}|�}t|dd�dur'td��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.)�cryptography.x509.extensionsr)�getattr�ImportError�OpenSSL.cryptor+)r)r+rr
r
rr!�s���r!cCs@dd�}d|vr
|S||�}|durdStjdkr|�d�}|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}z%dD]}|�|�r#|t|�d�}|�d�|�|�WSq|�|�WS|jjy5YdSw)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)z*.�.�ascii)�idna�
startswith�len�encode�core�	IDNAError)�namer3�prefixr
r
r�idna_encode�s
��z'_dnsname_to_stdlib.<locals>.idna_encode�:N)�r�utf-8)�sys�version_info�decode)r9r;r
r
r�_dnsname_to_stdlib�s

rBcCs�t|d�r
|��}ntt|j�}z
|j�tj�j	}Wn+tj
y&gYStjttj
tfyE}zt�d|�gWYd}~Sd}~wwdd�tt|�tj��D�}|�dd�|�tj�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|]
}|durd|f�qS)N�DNSr
�rr9r
r
r�
<listcomp>s
�z%get_subj_alt_name.<locals>.<listcomp>css�|]	}dt|�fVqdS)z
IP AddressN)�strrEr
r
rr s�
�z$get_subj_alt_name.<locals>.<genexpr>)�hasattrrCr�openssl_backendr,�
extensionsr*r�SubjectAlternativeName�value�ExtensionNotFound�DuplicateExtensionr�UnsupportedGeneralNameType�UnicodeError�log�warning�maprB�get_values_for_type�DNSName�extend�	IPAddress)�	peer_cert�cert�ext�e�namesr
r
r�get_subj_alt_name�s6

�����

�r]c@s�eZdZdZd!dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
d"dd�Zdd�Zdd�Zdd�Zd S)#�
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)�selfr`rarbr
r
r�__init__s

zWrappedSocket.__init__cC�
|j��Sr)ra�fileno�rer
r
rrh�
zWrappedSocket.filenocCs.|jdkr|jd8_|jr|��dSdS)Nr�)rcrd�closerir
r
r�_decref_socketioss

�zWrappedSocket._decref_socketiosc
Os�z|jj|i|��}W|Stjjy/}z|jr%|jdkr%WYd}~dStt|���d}~wtjj	yD|j�
�tjjkrCYdS�tjjydt
�|j|j���sZtd��|j|i|��YStjjyx}zt�d|��d}~ww)N����zUnexpected EOF��The read operation timed out�read error: %r)r`�recv�OpenSSL�SSL�SysCallErrorrb�args�SocketErrorrG�ZeroReturnError�get_shutdown�RECEIVED_SHUTDOWN�
WantReadErrorr�
wait_for_readra�
gettimeoutr�Error�ssl�SSLError)rerw�kwargs�datar[r
r
rrs$s(����zWrappedSocket.recvc
Os�z
|jj|i|��WStjjy-}z|jr#|jdkr#WYd}~dStt|���d}~wtjj	yB|j�
�tjjkrAYdS�tjjybt
�|j|j���sXtd��|j|i|��YStjjyv}zt�d|��d}~ww)Nrnrrqrr)r`�	recv_intortrurvrbrwrxrGryrzr{r|rr}rar~rrr�r�)rerwr�r[r
r
rr�=s&���zWrappedSocket.recv_intocCs|j�|�Sr)ra�
settimeout)rerr
r
rr�TszWrappedSocket.settimeoutc
Csh	z|j�|�WStjjy t�|j|j���st	��Yqtjj
y3}ztt|���d}~wwr)
r`�sendrtru�WantWriteErrorr�wait_for_writerar~rrvrxrG)rer�r[r
r
r�_send_until_doneWs��zWrappedSocket._send_until_donecCsBd}|t|�kr|�|||t��}||7}|t|�ksdSdS�Nr)r5r��SSL_WRITE_BLOCKSIZE)rer��
total_sent�sentr
r
r�sendallbs��zWrappedSocket.sendallcC�|j��dSr)r`�shutdownrir
r
rr�j�zWrappedSocket.shutdowncCsH|jdkrz	d|_|j��WStjjyYdSw|jd8_dS)NrkT)rcrdr`rlrtrurrir
r
rrlns
�zWrappedSocket.closeFcCsD|j��}|s	|S|rtj�tjj|�Sd|��jffft|�d�S)N�
commonName)�subject�subjectAltName)	r`�get_peer_certificatert�crypto�dump_certificate�
FILETYPE_ASN1�get_subject�CNr])re�binary_formrr
r
r�getpeercertxs
�zWrappedSocket.getpeercertcCrgr)r`�get_protocol_version_namerir
r
r�version�rjzWrappedSocket.versioncCs|jd7_dS�Nrk)rcrir
r
r�_reuse�szWrappedSocket._reusecCs(|jdkr|��dS|jd8_dSr�)rcrlrir
r
r�_drop�s
zWrappedSocket._dropN)T)F)rrr	�__doc__rfrhrmrsr�r�r�r�r�rlr�r�r�r�r
r
r
rr^s 


r^rocCs|jd7_t|||dd�S)NrkT)rl)rcr)re�mode�bufsizer
r
r�makefile�sr�c@s�eZdZdZdd�Zedd��Zejdd��Zedd��Zejd	d��Zd
d�Z	dd
�Z
ddd�Zddd�Zdd�Z
				ddd�ZdS)r"z�
    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||_tj�|j�|_d|_d|_dSr_)�_openssl_versions�protocolrtru�Context�_ctx�_options�check_hostname)rer�r
r
rrf�s

zPyOpenSSLContext.__init__cCs|jSr)r�rir
r
r�options�szPyOpenSSLContext.optionscCs||_|j�|�dSr)r�r��set_options�rerLr
r
rr��scCst|j��Sr)�_openssl_to_stdlib_verifyr��get_verify_moderir
r
r�verify_mode�r�zPyOpenSSLContext.verify_modecCs|j�t|t�dSr)r��
set_verify�_stdlib_to_openssl_verify�_verify_callbackr�r
r
rr��scCr�r)r��set_default_verify_pathsrir
r
rr��sz)PyOpenSSLContext.set_default_verify_pathscCs&t|tj�r|�d�}|j�|�dS)Nr>)�
isinstance�six�	text_typer6r��set_cipher_list)re�ciphersr
r
r�set_ciphers�s
zPyOpenSSLContext.set_ciphersNc
Cs�|dur	|�d�}|dur|�d�}z|j�||�|dur)|j�t|��WdSWdStjjy@}zt�d|��d}~ww)Nr>z'unable to load trusted certificates: %r)	r6r��load_verify_locationsrrtrurr�r�)re�cafile�capath�cadatar[r
r
rr��s

���z&PyOpenSSLContext.load_verify_locationscsR|j�|��durt�tj�s��d��|j��fdd��|j�|p%|�dS)Nr>cs�Srr
)�_��passwordr
r�<lambda>�sz2PyOpenSSLContext.load_cert_chain.<locals>.<lambda>)r��use_certificate_chain_filer�r��binary_typer6�
set_passwd_cb�use_privatekey_file)re�certfile�keyfiler�r
r�r�load_cert_chain�s
z PyOpenSSLContext.load_cert_chaincCsdd�|D�}|j�|�S)NcSsg|]}t�|��qSr
)r��
ensure_binary)r�pr
r
rrF�sz7PyOpenSSLContext.set_alpn_protocols.<locals>.<listcomp>)r��set_alpn_protos)re�	protocolsr
r
r�set_alpn_protocols�sz#PyOpenSSLContext.set_alpn_protocolsFTc
Cs�tj�|j|�}t|tj�r|�d�}|dur|�|�|�	�	z|�
�Wn+tjjy>t�
||���s<td��Yq tjjyR}zt�d|��d}~ww	t||�S)Nr>Tzselect timed outzbad handshake: %r)rtru�
Connectionr�r�r�r�r6�set_tlsext_host_name�set_connect_state�do_handshaker|rr}r~rrr�r�r^)re�sock�server_side�do_handshake_on_connectrb�server_hostname�cnxr[r
r
r�wrap_socket�s&

��
zPyOpenSSLContext.wrap_socket)NNN)NN)FTTN)rrr	r�rf�propertyr��setterr�r�r�r�r�r�r�r
r
r
rr"�s*





�r"cCs|dkSr�r
)r�r�err_no�	err_depth�return_coder
r
rr��sr�)ro)Lr��
__future__r�OpenSSL.SSLrt�cryptographyr�$cryptography.hazmat.backends.opensslrrI�)cryptography.hazmat.backends.openssl.x509r�cryptography.x509rr/�	Exception�iorrar
rxrr�packages.backports.makefiler�loggingr�r?�rr��	util.ssl_r�__all__r%�PROTOCOL_TLSru�
SSLv23_METHOD�PROTOCOL_TLSv1�TLSv1_METHODr�rHrrrrrr�	CERT_NONE�VERIFY_NONE�
CERT_OPTIONAL�VERIFY_PEER�
CERT_REQUIRED�VERIFY_FAIL_IF_NO_PEER_CERTr��dict�itemsr�r�r(r$r#r'�	getLoggerrrQrrr!rBr]�objectr^r�r"r�r
r
r
r�<module>s|/��

�


��

+6^

Spamworldpro Mini