File: //usr/lib/python3/dist-packages/twisted/test/__pycache__/ssl_helpers.cpython-310.pyc
o
�br � @ sr d Z ddlmZ ddlmZ ddlmZ ddlmZ eee �
d���d�j�Z
G dd � d ej�ZG d
d� d�ZdS )
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.
� )�SSL)�ssl)�nativeString)�FilePathzutf-8s
server.pemc @ s e Zd ZdZdZdd� ZdS )�ClientTLSContextz:
SSL Context Factory for client-side connections.
� c 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 �:/usr/lib/python3/dist-packages/twisted/test/ssl_helpers.py�
getContext s zClientTLSContext.getContextN)�__name__�
__module__�__qualname__�__doc__�isClientr
r r r r r s r c @ s* e Zd ZdZdZedfdd�Zdd� ZdS )�ServerTLSContextz:
SSL Context Factory for server-side connections.
r Nc C s || _ |d u r
tj}|| _d S )N)�filenamer r �_method)r
r �methodr r r �__init__- s
zServerTLSContext.__init__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
4 s zServerTLSContext.getContext)r r r r r �certPathr r
r r r r r &