403Webshell
Server IP : 162.144.4.212  /  Your IP : 216.73.216.108
Web Server : Apache
System : Linux gator2125.hostgator.com 5.14.0-162.23.1.9991722448259.nf.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 31 18:11:45 UTC 2024 x86_64
User : cozeellc ( 2980)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /usr/lib/python3.9/site-packages/oci/auth/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.9/site-packages/oci/auth/__pycache__/certificate_retriever.cpython-39.pyc
a

���f�I�	@s�ddlmZddlmZddlmZddlmZddlm	Z	ddl
ZddlZ
ddlmZddlZddlZddlZejjdgggd	�dd
ddd
d��d�����ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)�)�x509)�default_backend)�requests)�	HTTPError)�ServiceErrorN)�sixT)���i�i�����)Zservice_error_checkZservice_error_retry_configZservice_error_retry_on_any_5xxZ$retry_max_wait_between_calls_secondsZretry_base_sleep_time_secondsZretry_exponential_growth_factorZtotal_elapsed_time_seconds�c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�AbstractCertificateRetrievercKsdddd�|_dS)N)�certificate�private_key_pem�private_key��certificate_and_private_key��self�kwargs�r�B/usr/lib/python3.9/site-packages/oci/auth/certificate_retriever.py�__init__1s�z%AbstractCertificateRetriever.__init__cCstd��dS�Nz Subclasses should implement this��NotImplementedError�rrrr�refresh9sz$AbstractCertificateRetriever.refreshcCstd��dSrrrrrr�get_certificate_and_private_key=sz<AbstractCertificateRetriever.get_certificate_and_private_keycCstd��dSrrrrrr�get_certificate_as_certificateAsz;AbstractCertificateRetriever.get_certificate_as_certificatecCstd��dSrrrrrr�get_certificate_rawEsz0AbstractCertificateRetriever.get_certificate_rawcCstd��dSrrrrrr�get_private_key_pemIsz0AbstractCertificateRetriever.get_private_key_pemcCstd��dSrrrrrr�get_private_keyMsz,AbstractCertificateRetriever.get_private_keyN)
�__name__�
__module__�__qualname__rrrr r!r"r#rrrrr0srcsdeZdZdZdZ�fdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
�ZS)�UrlBasedCertificateRetrievera�
    A certificate retriever which reads PEM-format strings from URLs.

    :param str certificate_url:
        The URL from which to retrieve a certificate. It is assumed that what we retrieve is the PEM-formatted string for the certificate.
        This is mandatory

    :param str private_key_url: (optional)
        The URL from which to retrieve the private key corresponding to certificate_url (if any). It is assumed that what we retrieve is the PEM-formatted string for
        the private key.

    :param str passphrase: (optional)
        The passphrase of the private key (if any).

    :param obj retry_strategy: (optional)
        A retry strategy to use when retrieving the certificate and private key from the URLs provided to this class. This should be one of the strategies available in
        the :py:mod:`~oci.retry` module. By default this retriever will not perform any retries.

    :param bool log_requests: (optional)
        log_request if set to True will log the request url and response data when retrieving
        the certificate & corresponding private key (if there is one defined for this retriever)

    **Note:** This class is used internally, it is not recommended for user's direct use.
    icstt|���d|vrtd��|d|_|�d�|_|�d�|_|�d�|_t	�
d�tt
|���|_|j�t	���|�d�r�d|j_|j�t	j�nd	|j_|jr�t|jtj�r�|j�d
�|_t��|_t��|_|�dd�r�|jj�|�d��|� �dS)NZcertificate_urlz6certificate_url must be supplied as a keyword argument�private_key_url�
passphrase�retry_strategyz{}.{}Zlog_requestsFT�ascii�headers)!�superr'r�	TypeError�cert_url�getr(r)r*�loggingZ	getLogger�formatr$�id�loggerZ
addHandlerZNullHandlerZdisabledZsetLevel�DEBUG�
isinstancer�	text_type�encode�	threading�Lock�
_refresh_lockrZSession�requests_sessionr,�updaterr��	__class__rrrms(



z%UrlBasedCertificateRetriever.__init__cCsH|j��z,|jr"|j�|j�n|��W|j��n|j��0dS)zp
        Refresh the token by making a call to Identity for a new token.
        Returns the new token.
        N)r;�acquirer*Zmake_retrying_call�_refresh_inner�releaserrrrr�s

z$UrlBasedCertificateRetriever.refreshcCs"|j��|j��}|j��|S�z]
        Returns the certificate_and_private_key dictionary contained by this object
        �r;r@r�copyrB)rZret_valrrrr�s


z<UrlBasedCertificateRetriever.get_certificate_and_private_keycCs"|��}|rt�|t��SdSdS)�N
        Retrieves the certificate as a cryptography.x509.Certificate
        N)r!r�load_pem_x509_certificater)rZraw_certrrrr �sz;UrlBasedCertificateRetriever.get_certificate_as_certificatecCs&|j��|j��d}|j��|S�zH
        Retrieves a string containing the certificate contents
        rrD)rrrrrr!�s

z0UrlBasedCertificateRetriever.get_certificate_rawcCs&|j��|j��d}|j��|S)zK
        Retrievea a string containing the PEM-encoded private key
        rrD�rrrrrr"�s

z0UrlBasedCertificateRetriever.get_private_key_pemcCs&|j��|j��d}|j��|S�zI
        Retrieves the private key as a cryptography private key
        rrDrIrrrr#�s

z,UrlBasedCertificateRetriever.get_private_keyc
Cs�ddl}t��}|j�d|j�|jj|jddd�}|j�d�t	j
|j|jt
|j���|jd�d	d
���z|��Wn@ty�}z(t|jj|j|jjt|���WYd}~n
d}~00|jj|jdd�D]}|�|�q�|����|jd
<|��t|jd
tj ��r |jd
�!d�|jd
<|�"|jd
�|j#�r�t��}|j�d|j#�|jj|j#ddd�}|j�d�t	j
|j|jt
|j���|jd�d	d
���z|��WnBt�y�}z(t|jj|j|jjt|���WYd}~n
d}~00|jj|jdd�D]}|�|��q�|����|jd<|��t|jdtj ��rT|jd�!d�|jd<z |j$�%|jd|j&�|jd<Wn*|j'j(�y�t)d|jdd��Yn0dS)af
        Refreshes the certificate and its corresponding private key (if there is one defined for this retriever).
        This method represents the unit of retrying for the certificate retriever. It is intentionally coarse
        grained (e.g. if we retrieve the certificate but fail to retrieve the private key then we'll retry and
        retrieve both the certificate and private key again) to try and best maintain consistency in the data.

        For example, if we had separate retries for the certificate and the private key, in the scenario where
        a certificate was successfully retrieved but the private key failed, the private key we successfully
        retrieved upon retry may not relate to the certificate that we retrieved (e.g. because of rotation). This
        is still a risk in coarse grained retries, but hopefully a smaller one.
        rNz!Requesting certificate from : %s T)�
�<)�stream�timeoutz(Receiving certificate response......
{}
)�status_code�url�header�reason�)�indentF)Zdecode_contentrr+z!Requesting private key from : %s z(Receiving private key response......
{}
rr��certificate_type�certificate_raw)*�
oci.signerr�BytesIOr4�debugr/r<r0r2�pprintZpformatrOrP�dictr,�itemsrRZraise_for_statusrr�response�errno�str�rawrM�READ_CHUNK_BYTES�write�getvalue�stripr�closer6r7r8�_check_valid_certificate_stringr(�signer�load_private_keyr)�
exceptionsZInvalidPrivateKey�+InvalidCertificateFromInstanceMetadataError)r�ociZdownloaded_certificater^�e�chunkZdownloaded_private_key_rawrrrrA�sf��
2��
2��z+UrlBasedCertificateRetriever._refresh_innercCs6zt�|t��Wnty0td|d��Yn0dS)a�
        Determines whether a given string is a valid certificate. Valid in this context means that it
        can be parsed into a cryptography.io X509 certificate object. If the string is not valid then
        this method will throw an exception.

        :param str certificate_string_to_check:
            The certificate string to check. If it is valid then it should be a PEM-formatted string
            and able to be parsed into a cryptography.io X509 certificate object
        rrUN)rrGr�
ValueErrorrk)rZcertificate_string_to_checkrrrrgs
�z<UrlBasedCertificateRetriever._check_valid_certificate_string)r$r%r&�__doc__rbrrrr r!r"r#rArg�
__classcell__rrr>rr'Qs




Fr'csPeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
�ZS)�PEMStringCertificateRetrievera?
    A certificate retriever which is provided PEM format strings directly. This retriever is non-refreshable, and calling refresh() is a no-op.

    :param str certificate_pem:
        The PEM-formatted string of the certificate. This is mandatory.

    :param str private_key_pem (optional):
        The PEM-formatted string of the private key corresponding to certificate_pem (if any).

    :param str passphrase (optional):
        The passphrase of the private key (if any).

    **Note:** This class is used internally, it is not recommended for user's direct use.
    cs�ddl}tt|���d|vr&td��t|dtj�rL|d�d�|j	d<n|d|j	d<d|vr�|dr�t|dtj�r�|d�d�|j	d<n|d|j	d<d|vr�|dr�|d�d�}nd}|j
�|j	d|�|j	d<dS)	Nr�certificate_pemz6certificate_pem must be supplied as a keyword argumentr+rrr)r)rXr-rrrr.r6rr7r8rrhri)rrrlr)r>rrr4s$�z&PEMStringCertificateRetriever.__init__cCsdS)z�
        Since these are just the string, there is no refresh as such. A new object should be created
        if the strings change
        NrrrrrrQsz%PEMStringCertificateRetriever.refreshcCs
|j��SrC)rrErrrrrXsz=PEMStringCertificateRetriever.get_certificate_and_private_keycCst�|jdt��S)rFr)rrGrrrrrrr ^sz<PEMStringCertificateRetriever.get_certificate_as_certificatecCs
|jdSrHrrrrrr!dsz1PEMStringCertificateRetriever.get_certificate_rawcCs
|jdS)zL
        Retrieve a a string containing the PEM-encoded private key
        rrrrrrr"jsz1PEMStringCertificateRetriever.get_private_key_pemcCs
|jdSrJrrrrrr#psz-PEMStringCertificateRetriever.get_private_key)r$r%r&rprrrr r!r"r#rqrrr>rrr$srrcs(eZdZdZ�fdd�Zdd�Z�ZS)�FileBasedCertificateRetrievera/
    A specialization of PEMStringCertificateRetriever which reads certificates from a file. This retriever is non-refreshable, and calling refresh() is a no-op.

    :param str certificate_file_path:
        The file path from which to retrieve a certificate. It is assumed that what we retrieve is the PEM-formatted string for the certificate.
        This is mandatory

    :param str private_key_pem_file_path (optional):
        The file path from which to retrieve the private key corresponding to certificate_file_path (if any). It is assumed that what we retrieve is the PEM-formatted string for
        the private key.

    :param str passphrase (optional):
        The passphrase of the private key (if any).

    **Note:** This class is used internally, it is not recommended for user's direct use.
    csbd|vrtd��d|vr(|�|d�}nd}|�|d�||�d�d�}tt|�jfi|��dS)NZcertificate_file_pathz<certificate_file_path must be supplied as a keyword argumentZprivate_key_pem_file_pathr))rsrr))r.�_load_data_from_filer0r-rtr)rrrZparent_class_kwargsr>rrr�s�z&FileBasedCertificateRetriever.__init__cCsHtj�|�}t|dd��}|����}Wd�n1s:0Y|S)N�rb)�mode)�os�path�
expanduser�open�readre)r�filename�fZ	cert_datarrrru�s*z2FileBasedCertificateRetriever._load_data_from_file)r$r%r&rprrurqrrr>rrtwsrtcseZdZd�fdd�	Z�ZS)rkrNcs,||_||_tt|��d|j|jd��dS)NzTInvalid certificate returned from instance metadata. Expected a PEM-formatted string)�messagerVrW)rWrVr-rkr)rrVrWr>rrr�s
�z4InvalidCertificateFromInstanceMetadataError.__init__)rN)r$r%r&rrqrrr>rrk�srk)ZcryptographyrZcryptography.hazmat.backendsrZoci._vendorrZoci._vendor.requests.exceptionsrZoci.exceptionsrZ	oci.retryrlZos.pathrxrr9r1r[ZretryZRetryStrategyBuilderZadd_max_attemptsZadd_total_elapsed_timeZget_retry_strategyZ:INSTANCE_METADATA_URL_CERTIFICATE_RETRIEVER_RETRY_STRATEGY�objectrr'rrrt�	Exceptionrkrrrr�<module>s6
��
�!TS+

Youez - 2016 - github.com/yon3zu
LinuXploit