KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.41 (Ubuntu)
System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64
User : www-data ( 33)
PHP Version : 8.2.12
Disable Function : NONE
Directory :  /lib/python3/dist-packages/certbot/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/certbot/__pycache__/cert_manager.cpython-38.pyc
U

�]
<�@s:dZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddl
mZddl
m
Z
ddl
mZddl
mZdd	l
mZdd
lmZdd	lmZe�e�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z dd�Z!dd �Z"d.d"d#�Z#d/d$d%�Z$d&d'�Z%d(d)�Z&d*d+�Z'd,d-�Z(dS)0z Tools for managing certificates.�N)�List)�crypto_util)�errors)�
interfaces)�ocsp)�storage)�util)�oscCs$t�|�D]}tj||dd�q
dS)a`Update the certificate file family symlinks to use archive_dir.

    Use the information in the config file to make symlinks point to
    the correct archive directory.

    .. note:: This assumes that the installation is using a Reverter object.

    :param config: Configuration.
    :type config: :class:`certbot.configuration.NamespaceConfig`

    T)Zupdate_symlinksN)r�renewal_conf_files�
RenewableCert)�config�renewal_file�r�6/usr/lib/python3/dist-packages/certbot/cert_manager.py�update_live_symlinkssrcCs�tj�tj�}t|d�d}|j}|sX|jd�|�ddd�\}}|t	j
ksN|sXt�d��t
||�}|svt�d�|���t�|||�|jd	�||�d
d�dS)
z�Rename the specified lineage to the new name.

    :param config: Configuration.
    :type config: :class:`certbot.configuration.NamespaceConfig`

    �renamerz&Enter the new name for certificate {0}z--updated-cert-nameT)�flag�force_interactive�User ended interaction.z,No existing certificate with name {0} found.z Successfully renamed {0} to {1}.F��pauseN)�zope�	component�
getUtilityr�IDisplay�
get_certnames�new_certname�input�format�display_util�OKr�Error�lineage_for_certnameZConfigurationErrorrZrename_renewal_config�notification)r�disp�certnamer�code�lineagerrr�rename_lineage*s.�


���r(cCs�g}g}t�|�D]t}z$t�||�}t�|�|�|�Wqtk
r�}z,t�d||�t�	dt
���|�|�W5d}~XYqXqt|||�dS)z�Display information about certs configured with Certbot

    :param config: Configuration.
    :type config: :class:`certbot.configuration.NamespaceConfig`
    zIRenewal configuration file %s produced an unexpected error: %s. Skipping.�Traceback was:
%sN)
rr
rrZverify_renewable_cert�append�	Exception�loggerZwarning�debug�	traceback�
format_exc�_describe_certs)r�parsed_certs�parse_failuresr
Zrenewal_candidate�errr�certificatesEs
�r4cCsJt|ddd�}|D]2}t�||�tj�tj�}|jd�	|�dd�qdS)z;Delete Certbot files associated with a certificate lineage.�deleteT)�allow_multiplez.Deleted all files relating to certificate {0}.FrN)
rrZdelete_filesrrrrrr#r)r�	certnamesr%r$rrrr5[s��r5c	Cs�|j}tj|dd�zt�||�}Wntjk
r<YdSXzt�||�WStjtfk
r�t	�
d|�t	�
dt���YdSXdS)z)Find a lineage object with name certname.����modeNzRenewal conf file %s is broken.r))
�renewal_configs_dirr�make_or_verify_dirrZrenewal_file_for_certnamer�CertStorageErrorr�IOErrorr,r-r.r/)�
cli_configr%�configs_dirr
rrrr"hsr"cCst||�}|r|��SdS)z0Find the domains in the cert with name certname.N)r"�names)rr%r'rrr�domains_for_certnamexs
rBcs�fdd�}t||d�S)a~Find existing certs that match the given domain names.

    This function searches for certificates whose domains are equal to
    the `domains` parameter and certificates whose domains are a subset
    of the domains in the `domains` parameter. If multiple certificates
    are found whose names are a subset of `domains`, the one whose names
    are the largest subset of `domains` is returned.

    If multiple certificates' domains are an exact match or equally
    sized subsets, which matching certificates are returned is
    undefined.

    :param config: Configuration.
    :type config: :class:`certbot.configuration.NamespaceConfig`
    :param domains: List of domain names
    :type domains: `list` of `str`

    :returns: lineages representing the identically matching cert and the
        largest subset if they exist
    :rtype: `tuple` of `storage.RenewableCert` or `None`

    csb|\}}t|���}|t��kr&|}n4|�t���rZ|dkrB|}nt|�t|���krZ|}||fS)zsReturn cert as identical_names_cert if it matches,
           or subset_names_cert if it matches as subset
        N)�setrA�issubset�len)�candidate_lineage�rvZidentical_names_certZsubset_names_certZcandidate_names��domainsrr�update_certs_for_domain_matches�sz?find_duplicative_certs.<locals>.update_certs_for_domain_matches)NN)�_search_lineages)rrIrJrrHr�find_duplicative_certs}srLcs,|j���fdd�t���D�}|r(|SdS)aJ In order to match things like:
        /etc/letsencrypt/archive/example.com/chain1.pem.

        Anonymous functions which call this function are eventually passed (in a list) to
        `match_and_check_overlaps` to help specify the acceptable_matches.

        :param `.storage.RenewableCert` candidate_lineage: Lineage whose archive dir is to
            be searched.
        :param str filetype: main file name prefix e.g. "fullchain" or "chain".

        :returns: Files in candidate_lineage's archive dir that match the provided filetype.
        :rtype: list of str or None
    cs,g|]$}t�d���|�rtj��|��qS)z
{0}[0-9]*.pem)�re�matchrr	�path�join)�.0�f��archive_dir�filetyperr�
<listcomp>�s�z"_archive_files.<locals>.<listcomp>N)rTr	�listdir)rFrU�patternrrSr�_archive_files�s
rYcCsdd�dd�dd�dd�gS)z� Generates the list that's passed to match_and_check_overlaps. Is its own function to
    make unit testing easier.

    :returns: list of functions
    :rtype: list
    cSs|jS�N)Zfullchain_path��xrrr�<lambda>��z%_acceptable_matches.<locals>.<lambda>cSs|jSrZ��	cert_pathr[rrrr]�r^cSs
t|d�S)N�cert�rYr[rrrr]�r^cSs
t|d�S)N�	fullchainrbr[rrrr]�r^rrrrr�_acceptable_matches�s�rdcs(t�}t�|�fdd�dd��}|dS)a� If config.cert_path is defined, try to find an appropriate value for config.certname.

    :param `configuration.NamespaceConfig` cli_config: parsed command line arguments

    :returns: a lineage name
    :rtype: str

    :raises `errors.Error`: If the specified cert path can't be matched to a lineage name.
    :raises `errors.OverlappingMatchFound`: If the matched lineage's archive is shared.
    cs
�jdS)Nrr_r[�r?rrr]�r^z&cert_path_to_lineage.<locals>.<lambda>cSs|jSrZ)�lineagenamer[rrrr]�r^r)rd�match_and_check_overlaps)r?�acceptable_matchesrNrrer�cert_path_to_lineage�s
�ricsV��fdd�}t||g|�}|s8t�d�|jd���nt|�dkrNt���n|SdS)a Searches through all lineages for a match, and checks for duplicates.
    If a duplicate is found, an error is raised, as performing operations on lineages
    that have their properties incorrectly duplicated elsewhere is probably a bad idea.

    :param `configuration.NamespaceConfig` cli_config: parsed command line arguments
    :param list acceptable_matches: a list of functions that specify acceptable matches
    :param function match_func: specifies what to match
    :param function rv_func: specifies what to return

    cs`�fdd�|D�}g}|D]"}t|t�r2||7}q|�|�q���}||kr\|�����|S)z1Returns a list of matches using _search_lineages.csg|]}|���qSrr)rQ�func�rFrrrV�szBmatch_and_check_overlaps.<locals>.find_matches.<locals>.<listcomp>)�
isinstance�listr*)rFZreturn_valuerhZacceptable_matches_rv�itemrN��
match_func�rv_funcrkr�find_matches�s

z.match_and_check_overlaps.<locals>.find_matchesz!No match found for cert-path {0}!r�N)rKrr!rr`rEZOverlappingMatchFound)r?rhrprqrrZmatchedrrorrg�s
rgFc
	Cs*g}t��}|jr&|j|jkr&|s&dS|jrDt|j��|���sDdStj	�
tj���}g}|j
rj|�d�|j|kr�|�d�n|�|�r�|�d�|r�dd�|�}nB|j|}|jdkr�d}n(|jdkr�d	�|jd
�}nd�|j�}d�|j|�}	|�d
�|jd�|���|	|j|j��d�|�S)zJ Returns a human readable description of info about a RenewableCert object�Z	TEST_CERTZEXPIREDZREVOKEDz	INVALID: z, rszVALID: 1 dayzVALID: {0} hour(s)izVALID: {0} daysz	{0} ({1})zq  Certificate Name: {0}
    Domains: {1}
    Expiry Date: {2}
    Certificate Path: {3}
    Private Key Path: {4}� )rZRevocationCheckerr%rfrIrCrDrA�pytzZUTCZfromutc�datetimeZutcnowZis_test_certr*Z
target_expiryZocsp_revokedrPZdaysrZsecondsrcZprivkey)
rraZskip_filter_checks�certinfoZcheckerZnowZreasonsZstatusZdiffZvalid_stringrrr�human_readable_cert_info�s>






�
rycCs�|j}|r|g}n�tj�tj�}t�|�}dd�|D�}|sFt�	d��|r�|sZd�
|�}	n|}	|j|	|ddd�\}
}|
tj
kr�t�	d��nZ|s�d	�
|�}	n|}	|j|	|ddd�\}
}|
tj
ks�|td
t|��kr�t�	d��||g}|S)z9Get certname from flag, interactively, or error out.
    cSsg|]}t�|��qSr)rZlineagename_for_filename)rQ�namerrrrV-sz!get_certnames.<locals>.<listcomp>zNo existing certificates found.z+Which certificate(s) would you like to {0}?z--cert-nameT)Zcli_flagrrz(Which certificate would you like to {0}?r)r%rrrrrrr
rr!rZ	checklistrr Zmenu�rangerE)rZverbr6Z
custom_promptr%r7r$�	filenames�choices�promptr&�indexrrrr$sB

�

�


rcCsdd�dd�|D��S)zFFormat a results report for a category of single-line renewal outcomesz  z
  css|]}t|�VqdSrZ)�str)rQ�msgrrr�	<genexpr>Msz _report_lines.<locals>.<genexpr>)rP)Zmsgsrrr�
_report_linesKsr�cCs(g}|D]}|�t||��qd�|�S)z)Format a results report for a parsed cert�
)r*ryrP)rr1rxrarrr�_report_human_readableOsr�cCs�g}|j}|s|s|d�nL|rP|js,|jr0dnd}|d�|��|t||��|rh|d�|t|��tj�t	j
�}|jd�|�ddd�d	S)
z/Print information about the certs we know aboutzNo certs found.z	matching rtzFound the following {0}certs:z3
The following renewal configurations were invalid:r�F)rZwrapN)
r*r%rIrr�r�rrrrrr#rP)rr1r2�outZnotifyrNr$rrrr0Vs
r0c
Gs�|j}tj|dd�|}t�|�D]`}zt�||�}Wn:tjtfk
rpt	�
d|�t	�
dt���Yq"YnX|||f|��}q"|S)a�Iterate func over unbroken lineages, allowing custom return conditions.

    Allows flexible customization of return values, including multiple
    return values and complex checks.

    :param `configuration.NamespaceConfig` cli_config: parsed command line arguments
    :param function func: function used while searching over lineages
    :param initial_rv: initial return value of the function (any type)

    :returns: Whatever was specified by `func` if a match is found.
    r8r9z)Renewal conf file %s is broken. Skipping.r))
r;rr<rr
rrr=r>r,r-r.r/)r?rjZ
initial_rv�argsr@rGr
rFrrrrKks
rK)F)FN))�__doc__rwZloggingrMr.rvZzope.componentrZacme.magic_typingrZcertbotrrrrrrZcertbot.compatr	Zcertbot.displayrZ	getLogger�__name__r,rr(r4r5r"rBrLrYrdrirgryrr�r�r0rKrrrr�<module>sB

,
!
+
'

Anon7 - 2021