
    Bfi                         d Z dZdZdZdZdZdZddlZej                  d   d	kD  rddl	m
Z nddlZdd
lmZ ddlmZ  G d de      ZddZddddddej(                  dfdZ	 ddZy)zundg_httpsclient SSL Context utilities module containing convenience routines
for setting SSL context configuration.

zP J Kershaw (STFC)z09/12/11z2(C) 2012 Science and Technology Facilities Councilz-BSD - see LICENSE file in top-level directoryzPhilip.Kershaw@stfc.ac.ukz$Id$    N   )SSL)ServerSSLCertVerificationc                       e Zd ZdZ	 	 ddZy)SSlContextConfigz
    Holds configuration options for creating a SSL context. This is used as a
    template to create the contexts with specific verification callbacks.
    Nc                 J    || _         || _        || _        || _        || _        y N)key_file	cert_filepem_fileca_dirverify_peer)selfr
   r   r   r   r   s         r/var/www/html/BankruptcyAI-uat/bankruptcy-ai/venv/lib/python3.12/site-packages/ndg/httpsclient/ssl_context_util.py__init__zSSlContextConfig.__init__   s&     " &    )NNNNF)__name__
__module____qualname____doc__r    r   r   r   r      s     MQ"'r   r   Fc                     t        | j                  | j                  | j                  | j                  | j
                  |      S r	   )make_ssl_contextr
   r   r   r   r   )
ssl_configurls     r   make_ssl_context_from_configr   %   s;    J//1E1E&//1B1B&22C9 9r   c                    t        j                  |      }|r|j                  |       rfd}	|j                  |	       | r|j	                  |        n|r|j	                  |       |s|r|j                  ||       n|j                          d }
|
}|rC|j                  d       |rt        ||       |S |j                  t         j                  |       |S |j                  t         j                  |       |S )zL
    Creates SSL context containing certificate and key file locations.
    c                     S r	   r   )max_passphrase_len
set_promptuserdatakey_file_passphrases      r   <lambda>z"make_ssl_context.<locals>.<lambda>8   s    . r   c                     |S )zrDefault certification verification callback.
        Performs no checks and returns the status passed in.
        r   )connx509errnumerrdepthpreverify_oks        r   	_callbackz#make_ssl_context.<locals>._callbackF   s
     r   	   )r   Contextuse_certificate_fileset_passwd_cbuse_privatekey_fileload_verify_locationsset_default_verify_pathsset_verify_depth&set_peer_verification_for_url_hostname
set_verifyVERIFY_PEERVERIFY_NONE)r
   r   r   r   r   r   methodr"   ssl_context	passwd_cbr*   verify_callbacks          `    r   r   r   +   s     ++f%K ((3/	!!),''1	''	26))(F;,,.  O$$Q'2;D 	 ""3??OD  	s@r   c                    |r!| j                         t        j                  z  r^t        j                  |      }|j
                  }t        |      }|j                         }| j                  t        j                  |       yy)zbConvenience routine to set peer verification callback based on
    ServerSSLCertVerification class)hostnameN)	get_verify_moder   r5   	urlparse_urlparser<   r   get_verify_server_cert_funcr4   )r8   r   if_verify_enabledurlObjr<   server_ssl_cert_verifverify_callback_s          r   r3   r3   Z   si     !<!<!>!P##C(?? 98 L0LLNs0@A "Qr   )FN)F)r   
__author____date____copyright____license____contact____revision__sysversion_infourllib.parseparser>   r?   OpenSSLr   %ndg.httpsclient.ssl_peer_verificationr   objectr   r   TLSv1_2_METHODr   r3   r   r   r   <module>rS      s    "
D=) 
A$   K'v '9 #dT$!&D9K9K)-,` >C	Br   