o
    ¼>hæ  ã                   @  s~   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ee
e d¡ƒ d¡jƒZG d	d
„ d
ejƒZG dd„ dƒZdS )z“
Helper classes for twisted.test.test_ssl.

They are in a separate module so they will not prevent test_ssl importing if
pyOpenSSL is unavailable.
é    )Úannotations)ÚSSL)Ússl)ÚnativeString)ÚFilePathzutf-8s
   server.pemc                   @  s   e Zd ZdZdZddd„ZdS )	ÚClientTLSContextz:
    SSL Context Factory for client-side connections.
    é   ÚreturnúSSL.Contextc                 C  s   t  t j¡S )zæ
        Return an L{SSL.Context} to be use for client-side connections.

        Will not return a cached context.
        This is done to improve the test coverage as most implementation
        are caching the context.
        )r   ÚContextÚSSLv23_METHOD)Úself© r   úx/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/twisted/test/ssl_helpers.pyÚ
getContext   s   zClientTLSContext.getContextN©r	   r
   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚisClientr   r   r   r   r   r      s    r   c                   @  s.   e Zd ZdZdZedfdd
d„Zddd„ZdS )ÚServerTLSContextz:
    SSL Context Factory for server-side connections.
    r   NÚfilenameústr | bytesÚmethodú
int | Noner	   ÚNonec                 C  s   || _ |d u r
tj}|| _d S )N)r   r   r   Ú_method)r   r   r   r   r   r   Ú__init__.   s   
zServerTLSContext.__init__r
   c                 C  s(   t  | j¡}| | j¡ | | j¡ |S )zæ
        Return an L{SSL.Context} to be use for server-side connections.

        Will not return a cached context.
        This is done to improve the test coverage as most implementation
        are caching the context.
        )r   r   r   Úuse_certificate_filer   Úuse_privatekey_file)r   Úctxr   r   r   r   7   s   zServerTLSContext.getContext)r   r   r   r   r	   r   r   )r   r   r   r   r   ÚcertPathr   r   r   r   r   r   r   '   s    ÿ	r   N)r   Ú
__future__r   ÚOpenSSLr   Útwisted.internetr   Útwisted.python.compatr   Útwisted.python.filepathr   Ú__file__ÚencodeÚsiblingÚpathr"   ÚClientContextFactoryr   r   r   r   r   r   Ú<module>   s   