Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/cheroot/ssl/__pycache__/pyopenssl.cpython-39.pyc
Ðазад
a p�h�3 � @ s d Z ddlZddlZddlZddlZzHddlZddlmZ ddlmZ z ej Z W n eyh ejZ Y n0 W n e y� dZY n0 ddlmZ ddlmZmZ dd lmZmZ G d d� d�ZG dd � d ee�ZG dd� dee�ZG dd� d�ZG dd� ded�ZG dd� de�ZdS )a� A library for integrating :doc:`pyOpenSSL <pyopenssl:index>` with Cheroot. The :py:mod:`OpenSSL <pyopenssl:OpenSSL>` module must be importable for SSL/TLS/HTTPS functionality. You can obtain it from `here <https://github.com/pyca/pyopenssl>`_. To use this module, set :py:attr:`HTTPServer.ssl_adapter <cheroot.server.HTTPServer.ssl_adapter>` to an instance of :py:class:`ssl.Adapter <cheroot.ssl.Adapter>`. There are two ways to use :abbr:`TLS (Transport-Level Security)`: Method One ---------- * :py:attr:`ssl_adapter.context <cheroot.ssl.pyopenssl.pyOpenSSLAdapter.context>`: an instance of :py:class:`SSL.Context <pyopenssl:OpenSSL.SSL.Context>`. If this is not None, it is assumed to be an :py:class:`SSL.Context <pyopenssl:OpenSSL.SSL.Context>` instance, and will be passed to :py:class:`SSL.Connection <pyopenssl:OpenSSL.SSL.Connection>` on bind(). The developer is responsible for forming a valid :py:class:`Context <pyopenssl:OpenSSL.SSL.Context>` object. This approach is to be preferred for more flexibility, e.g. if the cert and key are streams instead of files, or need decryption, or :py:data:`SSL.SSLv3_METHOD <pyopenssl:OpenSSL.SSL.SSLv3_METHOD>` is desired instead of the default :py:data:`SSL.SSLv23_METHOD <pyopenssl:OpenSSL.SSL.SSLv3_METHOD>`, etc. Consult the :doc:`pyOpenSSL <pyopenssl:api/ssl>` documentation for complete options. Method Two (shortcut) --------------------- * :py:attr:`ssl_adapter.certificate <cheroot.ssl.pyopenssl.pyOpenSSLAdapter.certificate>`: the file name of the server's TLS certificate. * :py:attr:`ssl_adapter.private_key <cheroot.ssl.pyopenssl.pyOpenSSLAdapter.private_key>`: the file name of the server's private key file. Both are :py:data:`None` by default. If :py:attr:`ssl_adapter.context <cheroot.ssl.pyopenssl.pyOpenSSLAdapter.context>` is :py:data:`None`, but ``.private_key`` and ``.certificate`` are both given and valid, they will be read, and the context will be automatically created from them. .. spelling:: pyopenssl � N)�SSL)�crypto� )�Adapter� )�errors�server)�StreamReader�StreamWriterc sV e Zd ZdZdZdZdd� Z� fdd�Zd� fd d � Z� fdd�Z � fd d�Z � ZS )�SSLFileobjectMixinz#Base mixin for a TLS socket stream.� g{�G�z�?c O s~ t � � }z||i |��W S tjy: t �| j� Y �n" tjyZ t �| j� Y �n tjy� } zX|r�|jdkr�W Y d}~dS |jd }|r�|tj v r�W Y d}~dS t �|��W Y d}~n�d}~0 tj�yZ } zv|r�|jdkr�W Y d}~dS d}z|jd d d }W n t �y& Y n0 |dk�r:t�� �tj|j� �W Y d}~n d}~0 0 t � � | | jkrt �d��qdS )z�Wrap the given call with TLS error-trapping. is_reader: if False EOF errors will be raised. If True, EOF errors will return "" (to emulate normal sockets). )���zUnexpected EOFN� r r zhttp requestz timed out)�timer Z WantReadError�sleep� ssl_retryZWantWriteErrorZSysCallError�argsr Zsocket_errors_to_ignore�socket�error�Error� IndexErrorZ NoSSLErrorZ FatalSSLAlert�ssl_timeout�timeout) �selfZ is_reader�callr �kwargs�start�eZerrnumZthirdarg� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/cheroot/ssl/pyopenssl.py� _safe_callR s6 "zSSLFileobjectMixin._safe_callc s | � dtt| �j|�S )z*Receive message of a size from the socket.T)r �superr �recv�r �size�� __class__r r r"