HEX
Server: Apache/2.4.65 (Debian)
System: Linux kubikelcreative 5.10.0-35-amd64 #1 SMP Debian 5.10.237-1 (2025-05-19) x86_64
User: www-data (33)
PHP: 8.4.13
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/urllib3/util/__pycache__/ssltransport.cpython-39.pyc
a

��fg��@sBddlZddlZddlZddlmZddlZdZGdd�d�ZdS)�N)�ProxySchemeUnsupportedi@c@s�eZdZdZedd��Zd:dd�Zdd	�Zd
d�Zdd
�Z	d;dd�Z
d<dd�Zd=dd�Zd>dd�Z
d?dd�Zd@dd�Zdd�Zdd �ZdAd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�ZdBd6d7�Zd8d9�ZdS)C�SSLTransportaL
    The SSLTransport wraps an existing socket and establishes an SSL connection.

    Contrary to Python's implementation of SSLSocket, it allows you to chain
    multiple TLS connections together. It's particularly useful if you need to
    implement TLS within TLS.

    The class supports most of the socket API operations.
    cCs&t|d�s"tjrtd��ntd��dS)z�
        Raises a ProxySchemeUnsupported if the provided ssl_context can't be used
        for TLS in TLS.

        The only requirement is that the ssl_context provides the 'wrap_bio'
        methods.
        �wrap_biozKTLS in TLS requires SSLContext.wrap_bio() which isn't supported on Python 2zXTLS in TLS requires SSLContext.wrap_bio() which isn't available on non-native SSLContextN)�hasattr�sixZPY2r)�ssl_context�r�;/usr/lib/python3/dist-packages/urllib3/util/ssltransport.py�$_validate_ssl_context_for_tls_in_tlss

��z1SSLTransport._validate_ssl_context_for_tls_in_tlsNTcCsHt��|_t��|_||_||_|j|j|j|d�|_|�|jj	�dS)zV
        Create an SSLTransport around socket using the provided ssl_context.
        )�server_hostnameN)
�sslZ	MemoryBIO�incoming�outgoing�suppress_ragged_eofs�socketr�sslobj�_ssl_io_loopZdo_handshake)�selfrrrrrrr	�__init__,s


�zSSLTransport.__init__cCs|S�Nr�rrrr	�	__enter__?szSSLTransport.__enter__cGs|��dSr)�close)r�_rrr	�__exit__BszSSLTransport.__exit__cCs
|j��Sr)r�filenorrrr	rEszSSLTransport.fileno�cCs|�||�Sr)�_wrap_ssl_read)r�len�bufferrrr	�readHszSSLTransport.readrcCs|dkrtd��|�|�S)Nrz+non-zero flags not allowed in calls to recv)�
ValueErrorr)rr�flagsrrr	�recvKszSSLTransport.recvcCs>|dkrtd��|r&|dur&t|�}n|dur2d}|�||�S)Nrz0non-zero flags not allowed in calls to recv_intor)r!rr )rr�nbytesr"rrr	�	recv_intoPs
zSSLTransport.recv_intoc	Cs�|dkrtd��d}t|��f}|�d��<}t|�}||krV|�||d��}||7}q2Wd�n1sj0YWd�n1s�0YdS)Nrz.non-zero flags not allowed in calls to sendall�B)r!�
memoryview�castr�send)r�datar"�countZviewZ	byte_viewZamount�vrrr	�sendallYszSSLTransport.sendallcCs$|dkrtd��|�|jj|�}|S)Nrz+non-zero flags not allowed in calls to send)r!rr�write)rr*r"Zresponserrr	r)cszSSLTransport.send�rc
Cst|�hd�kstd|f��d|v}d|vp2|}|s@|s@J�d|v}d}	|rX|	d7}	|rd|	d7}	t�||	�}
|jjd7_|dur�d	}|d
kr�tj}|d
kr�|s�td��|
S|r�|r�t�|
|
|�}n&|r�t�|
|�}n|s�J�t�	|
|�}|r�|St�
||||�}||_|S)a
        Python's httpclient uses makefile and buffered io when reading HTTP
        messages and we need to support it.

        This is unfortunately a copy and paste of socket.py makefile with small
        changes to point to the socket directly.
        >�w�br/z&invalid mode %r (only r, w, b allowed)r0r/r1��N���rz!unbuffered streams must be binary)�setr!rZSocketIOZ_io_refs�io�DEFAULT_BUFFER_SIZE�BufferedRWPair�BufferedReader�BufferedWriter�
TextIOWrapper�mode)
rr<�	buffering�encoding�errors�newlineZwritingZreadingZbinaryZrawmode�rawr�textrrr	�makefileis@
zSSLTransport.makefilecCs|�|jj�dSr)rr�unwraprrrr	rD�szSSLTransport.unwrapcCs|j��dSr)rrrrrr	r�szSSLTransport.closeFcCs|j�|�Sr)r�getpeercert)rZbinary_formrrr	rE�szSSLTransport.getpeercertcCs
|j��Sr)r�versionrrrr	rF�szSSLTransport.versioncCs
|j��Sr)r�cipherrrrr	rG�szSSLTransport.ciphercCs
|j��Sr)r�selected_alpn_protocolrrrr	rH�sz#SSLTransport.selected_alpn_protocolcCs
|j��Sr)r�selected_npn_protocolrrrr	rI�sz"SSLTransport.selected_npn_protocolcCs
|j��Sr)r�shared_ciphersrrrr	rJ�szSSLTransport.shared_cipherscCs
|j��Sr)r�compressionrrrr	rK�szSSLTransport.compressioncCs|j�|�dSr)r�
settimeout)r�valuerrr	rL�szSSLTransport.settimeoutcCs
|j��Sr)r�
gettimeoutrrrr	rN�szSSLTransport.gettimeoutcCs|j��dSr)r�_decref_socketiosrrrr	rO�szSSLTransport._decref_socketiosc
Csbz|�|jj||�WStjy\}z.|jtjkrF|jrFWYd}~dS�WYd}~n
d}~00dS)Nr)rrr r�SSLError�errnoZ
SSL_ERROR_EOFr)rrr�errr	r�szSSLTransport._wrap_ssl_readc
Gs�d}d}|r�d}z||�}WnBtjy^}z(|jtjtjfvrD|�|j}WYd}~n
d}~00|j��}|j�|�|dur�d}q|tjkr|j�	t
�}|r�|j�|�q|j�
�q|S)z>Performs an I/O loop between incoming/outgoing and the socket.TNF)rrPrQZSSL_ERROR_WANT_READZSSL_ERROR_WANT_WRITErr rr-r#�
SSL_BLOCKSIZEr
r.Z	write_eof)r�func�argsZshould_loopZretrQrRZbufrrr	r�s(

zSSLTransport._ssl_io_loop)NT)rN)rr)Nr)r)r)r/NNNN)F)N)�__name__�
__module__�__qualname__�__doc__�staticmethodr
rrrrr r#r%r-r)rCrDrrErFrGrHrIrJrKrLrNrOrrrrrr	rs:

�



	


�
-

	r)r6rrZurllib3.exceptionsrrrSrrrrr	�<module>s