Ë
    õ%9j+  ã                   óF   — d Z ddlmZ ddlmZ ddlmZ d
d„Zd„ Zd„ Z	d„ Z
y	)zUtilites for mutual TLS.é    )Úgetenv)Ú
exceptions)Ú_mtls_helperc                 óâ   — | r%t        j                  t         j                  «      	 �yt        j                  t         j                  «      	 �yt	        d«      }|rt        j                  |«      �yy)a2  Check if default client SSL credentials exists on the device.

    Args:
       include_context_aware (bool): include_context_aware indicates if context_aware
       path location will be checked or should it be skipped.

    Returns:
        bool: indicating if the default client cert source exists.
    TÚGOOGLE_API_CERTIFICATE_CONFIGF)r   Ú_check_config_pathÚCONTEXT_AWARE_METADATA_PATHÚ&CERTIFICATE_CONFIGURATION_DEFAULT_PATHr   )Úinclude_context_awareÚcert_config_paths     úV/var/www/html/truck-me/venv/lib/python3.12/site-packages/google/auth/transport/mtls.pyÚhas_default_client_cert_sourcer      su   € ñ 	Ü×+Ñ+¬L×,TÑ,TÓUØðð ä×'Ñ'Ü×?Ñ?ó	
ð ð	ð
 ÜÐ=Ó>ÐáÜ×+Ñ+Ð,<Ó=ÐIàØó    c                  óN   — t        d¬«      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.
    T©r   z(Default client cert source doesn't existc                  ó¤   — 	 t        j                  «       \  } }}||fS # t        t        t        f$ r}t        j                  |«      }||‚d }~ww xY w)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>.callbackG   sZ   € ð	*Ü'3×'KÑ'KÓ'MÑ$ˆAˆz˜9ð
 ˜9Ð$Ð$øô	 œ¤zÐ2ò 	*Ü ×6Ñ6°zÓBˆGØ˜zÐ)ûð	*ús   ‚ žA²A
Á
A©r   r   r   )r   s    r   Údefault_client_cert_sourcer   7   s.   € ô *ÀÕEÜ×.Ñ.Ø6ó
ð 	
ò%ð €Or   c                 óX   ‡ ‡— t        d¬«      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.
    Tr   z2Default client encrypted cert source doesn't existc                  ó€  •— 	 t        j                  d¬«      \  } }}}t        ‰d«      5 }|j                  |«       d d d «       t        ‰	d«      5 }|j                  |«       d d d «       ‰‰	|fS # 1 sw Y   Œ4xY w# 1 sw Y   ŒxY w# t        j
                  t        f$ r}t	        j                  |«      }||‚d }~ww xY w)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>.callbackk   sÅ   ø€ ð	*ô ×7Ñ7ÈtÔTñØØØØ ä�i Ó&ð ,¨)Ø—‘ 
Ô+÷,ä�h Ó%ð *¨Ø—‘˜yÔ)÷*ð ˜(Ð$4Ð4Ð4÷,ð ,ú÷*ð *ûä×*Ñ*¬GÐ4ò 	*Ü ×6Ñ6°zÓBˆGØ˜zÐ)ûð	*úsE   ƒ'B ªA/¼B ÁA;Á"B Á/A8Á4B Á;BÂ B ÂB=Â B8Â8B=r   )r+   r,   r   s   `` r   Ú$default_client_encrypted_cert_sourcer-   S   s/   ù€ ô& *ÀÕEÜ×.Ñ.Ø@ó
ð 	
õ5ð$ €Or   c                  ó*   — t        j                  «       S )ad  Returns boolean for whether the client certificate should be used for mTLS.

    This is a wrapper around _mtls_helper.check_use_client_cert().
    If GOOGLE_API_USE_CLIENT_CERTIFICATE is set to true or false, a corresponding
    bool value will be returned
    If GOOGLE_API_USE_CLIENT_CERTIFICATE is unset, the value will be inferred by
    reading a file pointed at by GOOGLE_API_CERTIFICATE_CONFIG, and verifying it
    contains a "workload" section. If so, the function will return True,
    otherwise False.

    Returns:
       bool: indicating whether the client certificate should be used for mTLS.
    )r   Úcheck_use_client_cert© r   r   Úshould_use_client_certr1   €   s   € ô ×-Ñ-Ó/Ð/r   N)T)Ú__doc__Úosr   Úgoogle.authr   Úgoogle.auth.transportr   r   r   r-   r1   r0   r   r   ú<module>r6      s)   ðñ å å "Ý .óò@ò8*óZ0r   