
    @f                     4    d Z ddlmZ ddlmZ d Zd Zd ZdS )zUtilites for mutual TLS.    )
exceptions)_mtls_helperc                  F    t          j        t           j                  } | duS )zCheck if default client SSL credentials exists on the device.

    Returns:
        bool: indicating if the default client cert source exists.
    N)r   _check_dca_metadata_pathCONTEXT_AWARE_METADATA_PATH)metadata_paths    i/home/panchajanya/Development/work/volatility3/lib/python3.11/site-packages/google/auth/transport/mtls.pyhas_default_client_cert_sourcer
      s)     !90 M $$    c                  P    t                      st          j        d          d } | S )a  Get a callback which returns the default client SSL credentials.

    Returns:
        Callable[[], [bytes, bytes]]: A callback which returns the default
            client certificate bytes and private key bytes, both in PEM format.

    Raises:
        google.auth.exceptions.DefaultClientCertSourceError: If the default
            client SSL credentials don't exist or are malformed.
    z(Default client cert source doesn't existc                      	 t          j                    \  } }}n6# t          t          t          f$ r}t          j        |          }||d }~ww xY w||fS )N)r   get_client_cert_and_keyOSErrorRuntimeError
ValueErrorr   MutualTLSChannelError)_
cert_bytes	key_bytes
caught_excnew_excs        r	   callbackz,default_client_cert_source.<locals>.callback1   si    	*'3'K'M'M$Az99z2 	* 	* 	* 6zBBGz)	* 9$$s    AAAr
   r   r   )r   s    r	   default_client_cert_sourcer   !   s@     *++ 
.6
 
 	
% % % Or   c                 Z     t                      st          j        d           fd}|S )at  Get a callback which returns the default encrpyted client SSL credentials.

    Args:
        cert_path (str): The cert file path. The default client certificate will
            be written to this file when the returned callback is called.
        key_path (str): The key file path. The default encrypted client key will
            be written to this file when the returned callback is called.

    Returns:
        Callable[[], [str, str, bytes]]: A callback which generates the default
            client certificate, encrpyted private key and passphrase. It writes
            the certificate and private key into the cert_path and key_path, and
            returns the cert_path, key_path and passphrase bytes.

    Raises:
        google.auth.exceptions.DefaultClientCertSourceError: If any problem
            occurs when loading or saving the client certificate and key.
    z2Default client encrypted cert source doesn't existc                     	 t          j        d          \  } }}}t          d          5 }|                    |           d d d            n# 1 swxY w Y   t          	d          5 }|                    |           d d d            n# 1 swxY w Y   n5# t          j        t          f$ r}t	          j        |          }||d }~ww xY w	|fS )NT)generate_encrypted_keywb)r   get_client_ssl_credentialsopenwriter   ClientCertErrorr   r   )
r   r   r   passphrase_bytes	cert_filekey_filer   r   	cert_pathkey_paths
           r	   r   z6default_client_encrypted_cert_source.<locals>.callbackU   sd   	* 7tTTT i&& ,)
+++, , , , , , , , , , , , , , ,h%% *y)))* * * * * * * * * * * * * * **G4 	* 	* 	* 6zBBGz)	* ($444s^   *B AB AB AB *B B BB BB C
.CC
r   )r&   r'   r   s   `` r	   $default_client_encrypted_cert_sourcer(   =   sQ    & *++ 
.@
 
 	
5 5 5 5 5 5$ Or   N)__doc__google.authr   google.auth.transportr   r
   r   r(    r   r	   <module>r-      sh      " " " " " " . . . . . .	% 	% 	%  8* * * * *r   