§
    ¬˜ºh€  ã                   ó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                  óŠ   — t          j        t           j        ¦  «        	 �dS t          j        t           j        ¦  «        	 �dS dS )z“Check if default client SSL credentials exists on the device.

    Returns:
        bool: indicating if the default client cert source exists.
    NTF)r   Ú_check_config_pathÚCONTEXT_AWARE_METADATA_PATHÚ&CERTIFICATE_CONFIGURATION_DEFAULT_PATH© ó    úb/var/www/html/services/rag-service/venv/lib/python3.11/site-packages/google/auth/transport/mtls.pyÚhas_default_client_cert_sourcer      sP   € õ 	Ô'­Ô(PÑQÔQØð	ð ˆtåÔ'ÝÔ?ñ	
ô 	
ð ð	ð
 ˆtØˆ5r
   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>.callback:   si   € ð	*Ý'3Ô'KÑ'MÔ'MÑ$ˆAˆz˜9˜9øÝ�¥zÐ2ð 	*ð 	*ð 	*Ý Ô6°zÑBÔBˆGØ˜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>.callback^   sd  ø€ ð	*õ Ô7ÈtÐTÑTÔTñØØØØ å�i Ñ&Ô&ð ,¨)Ø—’ 
Ñ+Ô+Ð+ð,ð ,ð ,ñ ,ô ,ð ,ð ,ð ,ð ,ð ,ð ,øøøð ,ð ,ð ,ð ,å�h Ñ%Ô%ð *¨Ø—’˜yÑ)Ô)Ð)ð*ð *ð *ñ *ô *ð *ð *ð *ð *ð *ð *øøøð *ð *ð *ð *øøåÔ*­GÐ4ð 	*ð 	*ð 	*Ý Ô6°zÑBÔBˆGØ˜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)   F   sQ   øø€ õ& *Ñ+Ô+ð 
ÝÔ.Ø@ñ
ô 
ð 	
ð5ð 5ð 5ð 5ð 5ð 5ð$ €Or
   N)Ú__doc__Úgoogle.authr   Úgoogle.auth.transportr   r   r   r)   r	   r
   r   ú<module>r-      sh   ðð Ð à "Ð "Ð "Ð "Ð "Ð "Ø .Ð .Ð .Ð .Ð .Ð .ðð ð ð*ð ð ð8*ð *ð *ð *ð *r
   