
    Yf                       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
ej                  Z G 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                      e Zd ZdZdZddZdS )ClientTLSContextz:
    SSL Context Factory for client-side connections.
       returnSSL.Contextc                >    t          j        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)selfs    J/var/www/html/env/lib/python3.11/site-packages/twisted/test/ssl_helpers.py
getContextzClientTLSContext.getContext   s     {3,---    Nr   r   )__name__
__module____qualname____doc__isClientr    r   r   r	   r	      s9          H. . . . . .r   r	   c                  ,    e Zd ZdZdZedfdd
ZddZdS )ServerTLSContextz:
    SSL Context Factory for server-side connections.
    r   Nfilenamestr | bytesmethod
int | Noner   Nonec                >    || _         |t          j        }|| _        d S )N)r   r   r   _method)r   r   r   s      r   __init__zServerTLSContext.__init__.   s#     !>&Fr   r   c                    t          j        | 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   ctxs     r   r   zServerTLSContext.getContext7   sF     k$,''  ///...
r   )r   r   r   r    r   r!   r   )r   r   r   r   r   certPathr$   r   r   r   r   r   r   '   sY          H '/T         r   r   N)r   
__future__r   OpenSSLr   twisted.internetr   twisted.python.compatr   twisted.python.filepathr   __file__encodesiblingpathr)   ClientContextFactoryr	   r   r   r   r   <module>r4      s     # " " " " "                   . . . . . . , , , , , ,<!9!9::BB=QQVWW. . . . .s/ . . .$         r   