%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/internet/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/internet/__pycache__/ssl.cpython-312.pyc

�

Ϫ�f�!��Z�dZddlmZddlmZmZmZddlmZddl	m
Z
mZdZee
j�Gd�d��ZGd	�d
e�Zee
j�Gd�d��Zee
j"gd
�eej$�D����Gd�dej$��Zee
j"�Gd�dej&��ZGd�dej(�ZGd�dej*�ZddlmZmZmZmZmZmZmZm Z m!Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*gd�Z+y)a	
This module implements Transport Layer Security (TLS) support for Twisted.  It
requires U{PyOpenSSL <https://pypi.python.org/pypi/pyOpenSSL>}.

If you wish to establish a TLS connection, please use one of the following
APIs:

    - SSL endpoints for L{servers
      <twisted.internet.endpoints.SSL4ServerEndpoint>} and L{clients
      <twisted.internet.endpoints.SSL4ClientEndpoint>}

    - L{startTLS <twisted.internet.interfaces.ITLSTransport.startTLS>}

    - L{connectSSL <twisted.internet.interfaces.IReactorSSL.connectSSL>}

    - L{listenSSL <twisted.internet.interfaces.IReactorSSL.listenSSL>}

These APIs all require a C{contextFactory} argument that specifies their
security properties, such as certificate, private key, certificate authorities
to verify the peer, allowed TLS protocol versions, cipher suites, and so on.
The recommended value for this argument is a L{CertificateOptions} instance;
see its documentation for an explanation of the available options.

The C{contextFactory} name is a bit of an anachronism now, as context factories
have been replaced with "connection creators", but these objects serve the same
role.

Be warned that implementing your own connection creator (i.e.: value for the
C{contextFactory}) is both difficult and dangerous; the Twisted team has worked
hard to make L{CertificateOptions}' API comprehensible and unsurprising, and
the Twisted team is actively maintaining it to ensure that it becomes more
secure over time.

If you are really absolutely sure that you want to take on the risk of
implementing your own connection creator based on the pyOpenSSL API, see the
L{server connection creator
<twisted.internet.interfaces.IOpenSSLServerConnectionCreator>} and L{client
connection creator
<twisted.internet.interfaces.IOpenSSLServerConnectionCreator>} interfaces.

Developers using Twisted, please ignore the L{Port}, L{Connector}, and
L{Client} classes defined here, as these are details of certain reactors' TLS
implementations, exposed by accident (and remaining here only for compatibility
reasons).  If you wish to establish a TLS connection, please use one of the
APIs listed above.

@note: "SSL" (Secure Sockets Layer) is an antiquated synonym for "TLS"
    (Transport Layer Security).  You may see these terms used interchangeably
    throughout the documentation.
�)�annotations)�
implementedBy�implementer�implementer_only)�SSL)�
interfaces�tcpTc��eZdZdZdZd�Zy)�ContextFactoryz>A factory for SSL context objects, for server SSL connections.rc��t�)z4Return a SSL.Context object. override in subclasses.��NotImplementedError��selfs �6/usr/lib/python3/dist-packages/twisted/internet/ssl.py�
getContextzContextFactory.getContextKs��!�!�N)�__name__�
__module__�__qualname__�__doc__�isClientr�rrrrEs��H��H�"rrc�`�eZdZdZdZejejfd�Zd�Z	d�Z
d�Zd�Zy)�DefaultOpenSSLContextFactoryaQ
    L{DefaultOpenSSLContextFactory} is a factory for server-side SSL context
    objects.  These objects define certain parameters related to SSL
    handshakes and the subsequent connection.

    @ivar _contextFactory: A callable which will be used to create new
        context objects.  This is typically L{OpenSSL.SSL.Context}.
    Nc�\�||_||_||_||_|j	�y)z�
        @param privateKeyFileName: Name of a file containing a private key
        @param certificateFileName: Name of a file containing a certificate
        @param sslmethod: The SSL method to use
        N)�privateKeyFileName�certificateFileName�	sslmethod�_contextFactory�cacheContext)rrrrr s     r�__init__z%DefaultOpenSSLContextFactory.__init__\s1��#5���#6�� �"���.���
	
���rc��|j�x|j|j�}|jtj
�|j
|j�|j|j�||_yy�N)
�_contextr r�set_optionsr�OP_NO_SSLv2�use_certificate_filer�use_privatekey_filer�r�ctxs  rr!z)DefaultOpenSSLContextFactory.cacheContextrsf���=�=� ��&�&�t�~�~�6�C�
�O�O�C�O�O�,��$�$�T�%=�%=�>��#�#�D�$;�$;�<��D�M�!rc�@�|jj�}|d=|S)Nr%)�__dict__�copy)r�ds  r�__getstate__z)DefaultOpenSSLContextFactory.__getstate__|s ���M�M��� ��
�j�M��rc��||_yr$)r-)r�states  r�__setstate__z)DefaultOpenSSLContextFactory.__setstate__�s	����
rc��|jS)z(
        Return an SSL context.
        )r%rs rrz'DefaultOpenSSLContextFactory.getContext�s���}�}�r)
rrrrr%r�
TLS_METHOD�Contextr"r!r0r3rrrrrrPs7����H��.�.�����, ��
�rrc�J�eZdZdZdZejZejZ	d�Z
y)�ClientContextFactoryz"A context factory for SSL clients.�c���|j|j�}|jtjtj
ztjztjz�|Sr$)r �methodr&rr'�OP_NO_SSLv3�OP_NO_TLSv1�
OP_NO_TLSv1_1r*s  rrzClientContextFactory.getContext�sM���"�"�4�;�;�/������O�O�c�o�o�-����?�#�BS�BS�S�	
��
rN)rrrrrrr5r;r6r rrrrr8r8�s#��,��H��^�^�F��k�k�O�rr8c#�HK�|]}|tjk7s�|���y�wr$)r�
ITLSTransport)�.0�is  r�	<genexpr>rC�s����L�A�a�:�3K�3K�.K�a�L�s�"�"c��eZdZdZdd�Zd�Zy)�Clientz
    I am an SSL client.
    Nc�Z�||_tjj||||||�yr$)�
ctxFactoryr	rEr")r�host�port�bindAddressrG�	connector�reactors       rr"zClient.__init__�s%��$����
�
���D�$��k�9�g�Nrc��|j|j�|j�tjj|�yr$)�startTLSrG�startWritingr	rE�_connectDoners rrPzClient._connectDone�s0���
�
�d�o�o�&������
�
����%rr$)rrrrr"rPrrrrErE�s��
�O�
&rrEc�(�eZdZUdZded<d�Zd�Zy)�Serverz
    I am an SSL server.
    �Port�serverc��tjj|g|��i|��|j|jj
�yr$)r	rRr"rNrTrG)r�args�kwargss   rr"zServer.__init__�s4���
�
���D�2�4�2�6�2��
�
�d�k�k�,�,�-rc��td��)NzServer.getPeerCertificater
rs r�getPeerCertificatezServer.getPeerCertificate�s��!�"=�>�>rN)rrrr�__annotations__r"rYrrrrRrR�s���
�L�.�?rrRc�(�eZdZdZeZdZ	dd�Zd�Zy)rSz
    I am an SSL port.
    �TLSNc�Z�tjj||||||�||_yr$)r	rSr"rG)rrI�factoryrG�backlog�	interfacerLs       rr"z
Port.__init__�s'��	�����$��g�w�	�7�K�$��rc�H�tjj||�dzS)z|
        Override the normal prefix to include an annotation indicating this is a
        port for TLS connections.
        z (TLS))r	rS�
_getLogPrefix)rr^s  rrbzPort._getLogPrefix�s ��
�x�x�%�%�d�G�4�x�?�?r)�2�N)	rrrrrR�	transport�_typer"rbrrrrSrS�s%����I��E�LP�%�@rrSc��eZdZ	dd�Zd�Zy)�	ConnectorNc	�|�||_tjj|||||||�|j	�yr$)�contextFactoryr	rhr"r)rrHrIr^rj�timeoutrJrLs        rr"zConnector.__init__�s9��-����
�
���t�T�4��'�;�PW�X�	�!�!�#rc��t|j|j|j|j||j
�Sr$)rErHrIrJrjrLrs r�_makeTransportzConnector._makeTransport�s9����I�I��I�I���������L�L�

�	
rr$)rrrr"rmrrrrhrh�s��QU�$�
rrh)�DN�Certificate�CertificateRequest�DistinguishedName�KeyPair�OpenSSLAcceptableCiphers�OpenSSLCertificateOptions�OpenSSLDefaultPaths�OpenSSLDiffieHellmanParameters�PrivateCertificate�ProtocolNegotiationSupport�
TLSVersion�VerificationError�optionsForClientTLS�
platformTrust�protocolNegotiationMechanisms�trustRootFromCertificates)rrr8rqrnrorprwrr�AcceptableCiphers�CertificateOptions�DiffieHellmanParametersr|ruryrzr{rxr}r~N),r�
__future__r�zope.interfacerrr�OpenSSLr�twisted.internetrr	�	supported�IOpenSSLContextFactoryrrr8�
ISSLTransportrErRrSrh�twisted.internet._sslverifyrnrorprqrrrsrrtr�rurvr�rwrxryrzr{r|r}r~�__all__rrr�<module>r�s)��
1�f#�G�G��-��	�
�Z�
.�
.�/�"�"�0�"�8�>�8�v
�Z�
.�
.�/���0��$�����L��s�z�z�*�L��
&�S�Z�Z�
&�	�
&� 
�Z�
%�
%�&�
?�S�Z�Z�
?�'�
?� @�3�8�8�@�.
��
�
�
�,�����(�r

Zerion Mini Shell 1.0