U
    c6{iæ  ã                   @  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d„ZdS )ÚClientTLSContextz:
    SSL Context Factory for client-side connections.
    é   úSSL.Context©Úreturnc                 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   ú</tmp/pip-unpacked-wheel-hfbvu0bz/twisted/test/ssl_helpers.pyÚ
getContext   s    zClientTLSContext.getContextN)Ú__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dœdd	„Zd
dœdd„ZdS )ÚServerTLSContextz:
    SSL Context Factory for server-side connections.
    r   Nzstr | bytesz
int | NoneÚNone)ÚfilenameÚmethodr   c                 C  s   || _ |d krtj}|| _d S )N)r   r   r   Ú_method)r   r   r   r   r   r   Ú__init__.   s    zServerTLSContext.__init__r	   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   Zuse_certificate_filer   Zuse_privatekey_file)r   Úctxr   r   r   r   7   s    zServerTLSContext.getContext)r   r   r   r   r   ÚcertPathr   r   r   r   r   r   r   '   s    ÿ	r   N)r   Ú
__future__r   ZOpenSSLr   Ztwisted.internetr   Ztwisted.python.compatr   Ztwisted.python.filepathr   Ú__file__ÚencodeZsiblingÚpathr   ZClientContextFactoryr   r   r   r   r   r   Ú<module>   s   