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__/renewal.cpython-38.pyc
U

e�_�S�@s�dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZ
ddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZe�e �Z!ddddddddddddgZ"ddgZ#ddd d!gZ$e%e�&e$e#e"d"��Z'd#d$�Z(d%d&�Z)d'd(�Z*d)d*�Z+d+d,�Z,d-d.�Z-d/d0�Z.d1d2�Z/d3d4�Z0d5d6�Z1d7d8�Z2d9d:�Z3d;d<�Z4d=d>�Z5dS)?zGFunctionality for autorenewal and associated juggling of configurations�)�print_functionN)�List)�cli)�	constants)�crypto_util)�errors)�hooks)�
interfaces)�storage)�updater)�util)�os)�discoZ
config_dirZlogs_dirZwork_dirZ
user_agent�serverZaccount�
authenticator�	installer�
renew_hook�pre_hook�	post_hookZhttp01_addressZrsa_key_size�http01_portZmust_stapleZallow_subset_of_names�	reuse_keyZ	autorenew)�pref_challsc
CsXzt�||�}WnFtjtfk
rVtjddd�t�d|�t�dt�	��YdSXd|j
krrt�d|�dS|j
d}d	|kr�t�d
|�dSzt||�t||�WnRt
tjfk
�r�}z,t�d|t|��t�dt�	��WY�dSd}~XYnXzdd
�|��D�|_Wn:tjk
�rR}zt�d||�WY�dSd}~XYnX|S)a�Try to instantiate a RenewableCert, updating config with relevant items.

    This is specifically for use in renewal and enforces several checks
    and policies to ensure that we can try to proceed with the renewal
    request. The config argument is modified by including relevant options
    read from the renewal configuration file.

    :param configuration.NamespaceConfig config: configuration for the
        current lineage
    :param str full_path: Absolute path to the configuration file that
        defines this lineage

    :returns: the RenewableCert object or None if a fatal error occurred
    :rtype: `storage.RenewableCert` or NoneType

    �T)�exc_infoz2Renewal configuration file %s is broken. Skipping.�Traceback was:
%sN�
renewalparamsz<Renewal configuration file %s lacks renewalparams. Skipping.rzJRenewal configuration file %s does not specify an authenticator. Skipping.zHAn error occurred while parsing %s. The error was %s. Skipping the file.cSsg|]}t�|��qS�)rZenforce_domain_sanity)�.0�drr�1/usr/lib/python3/dist-packages/certbot/renewal.py�
<listcomp>]s�z!_reconstitute.<locals>.<listcomp>ztRenewal configuration file %s references a cert that contains an invalid domain name. The problem was: %s. Skipping.)r
Z
RenewableCertrZCertStorageError�IOError�logger�warning�debug�	traceback�
format_exc�
configuration� restore_required_config_elements�_restore_plugin_configs�
ValueError�Error�str�names�domainsZConfigurationError)�config�	full_path�renewal_candidater�errorrrr�
_reconstitute/sP
�
�
���r3cCsRd|krt�d�s|d|_d|krNt�d�sN|d}t|tj�rH|g}||_dS)z�
    webroot_map is, uniquely, a dict, and the general-purpose configuration
    restoring logic is not able to correctly parse it from the serialized
    form.
    �webroot_map�webroot_pathN)r�
set_by_clir4�
isinstance�six�string_typesr5)r/rZwprrr�_restore_webroot_confighs
r:cCs�g}|ddkrt||�n|�|d�|�d�dk	rF|�|d�t|�D]p}|�dd�}t�|�D]T\}}|�|d�rht�	|�sh|dkr�t
||t|��qht�|�}t
||||��qhqNdS)aSets plugin specific values in config from renewalparams

    :param configuration.NamespaceConfig config: configuration for the
        current lineage
    :param configobj.Section renewalparams: Parameters from the renewal
        configuration file that defines this lineage

    rZwebrootrN�-�_)�None�True�False)
r:�append�get�set�replacer8Z	iteritems�
startswithrr6�setattr�evalZ
argparse_type)r/rZplugin_prefixesZ
plugin_prefixZconfig_itemZconfig_value�castrrrr)ys
r)cCs�t�dtfftj�tt�t��tj�t	t�t
��tj�tt�t���}|D]4\}}||krJt
�|�sJ||||�}t|||�qJdS)aSets non-plugin specific values in config from renewalparams

    :param configuration.NamespaceConfig config: configuration for the
        current lineage
    :param configobj.Section renewalparams: parameters from the renewal
        configuration file that defines this lineage

    rN)�	itertools�chain�_restore_pref_challsr8Zmoves�zip�BOOL_CONFIG_ITEMS�repeat�
_restore_bool�INT_CONFIG_ITEMS�_restore_int�STR_CONFIG_ITEMS�_restore_strrr6rE)r/rZrequired_itemsZ	item_nameZrestore_func�valuerrrr(�s
�r(cCs t|tj�r|gn|}t�|�S)a�Restores preferred challenges from a renewal config file.

    If value is a `str`, it should be a single challenge type.

    :param str unused_name: option name
    :param value: option value
    :type value: `list` of `str` or `str`

    :returns: converted option value to be stored in the runtime config
    :rtype: `list` of `str`

    :raises errors.Error: if value can't be converted to an bool

    )r7r8r9rZparse_preferred_challenges)Zunused_namerSrrrrJ�srJcCs*|��}|dkr"t�d�||���|dkS)a%Restores an boolean key-value pair from a renewal config file.

    :param str name: option name
    :param str value: option value

    :returns: converted option value to be stored in the runtime config
    :rtype: bool

    :raises errors.Error: if value can't be converted to an bool

    )�trueZfalsez,Expected True or False for {0} but found {1}rT)�lowerrr+�format)�namerSZlowercase_valuerrrrN�s
�rNcCsX|dkr$|dkr$t�d�t�d�Sz
t|�WStk
rRt�d�|���YnXdS)a#Restores an integer key-value pair from a renewal config file.

    :param str name: option name
    :param str value: option value

    :returns: converted option value to be stored in the runtime config
    :rtype: int

    :raises errors.Error: if value can't be converted to an int

    rr=z!updating legacy http01_port valuez Expected a numeric value for {0}N)	r"�infor�flag_default�intr*rr+rV�rWrSrrrrP�s


rPcCs@|dkr0|tjkr0t�dtjd|�tjdS|dkr<dS|S)z�Restores an string key-value pair from a renewal config file.

    :param str name: option name
    :param str value: option value

    :returns: converted option value to be stored in the runtime config
    :rtype: str or None

    rz$Using server %s instead of legacy %sr=N)rZV1_URIr"rXZCLI_DEFAULTSr[rrrrR�s�
rRcCsL|jrt�d�dS|��r*t�d�dS|jr>t�d�dSt�d�dS)zDReturn true if any of the circumstances for automatic renewal apply.z+Auto-renewal forced with --force-renewal...Tz)Cert is due for renewal, auto-renewing...z<Cert not due for renewal, but simulating renewal for dry runzCert not yet due for renewalF)Zrenew_by_defaultr"r$Zshould_autorenewrX�dry_run)r/�lineagerrr�should_renews



r^c	Cs�t|j��}|��}W5QRXtj�tjj|�}dt|����	�k}t
�|j�r�t
�|�r^|r�|j
s�d�|���}t�d�|���dS)z9Do not renew a valid cert with one from a staging server!Zfakez, z�You've asked to renew/replace a seemingly valid certificate with a test certificate (domains: {0}). We will not do that unless you use the --break-my-certs flag!N)�open�cert�read�OpenSSLZcryptoZload_certificateZFILETYPE_PEM�reprZ
get_issuerrUrZ
is_stagingrZbreak_my_certs�joinr-rr+rV)r/r]�original_serverZthe_file�contentsZlatest_certZ	now_validr-rrr�_avoid_invalidating_lineage s ���rgcCs�|jd}|�dt�d��}t|||�|s4|��}|jrHtj�	|j
�nd}|�||�\}}}}	|jr~t
�dtj�|j��n*|��}
|�|
||j||�|�|���t�|||j�dS)zRenew a certificate lineage.rrNz(Dry run: skipping updating lineage at %s)r'rArrYrgr-rr
�path�normpathZprivkeyZobtain_certificater\r"r$�dirnamer`�latest_common_versionZsave_successorZpemZupdate_all_links_torrZlive_dir)r/r.Z	le_clientr]Zrenewal_paramsreZnew_keyZnew_certZ	new_chainr<Z
prior_versionrrr�
renew_cert6s
�rlcs �fdd�|D�}dd�|�S)z:Format a results report for a category of renewal outcomesc3s|]}d|�fVqdS)z%s (%s)Nr)r�m��categoryrr�	<genexpr>Oszreport.<locals>.<genexpr>z  z
  )rd)Zmsgsro�linesrrnr�reportMsrrcs\g}|j�tj�tj�}�fdd�}|jr:�d��d��d�|r\�d��t|d��|s�|s��d�|jdk	s�|j	dk	s�|j
dk	r��d	�n||r�|s��d
��t|d��n\|r�|s�|d�|t|d
��n<|�r|�r�d��t|d�d�|d�|t|d
��|�r,�d��t|d��|j�rD�d��d�|jd�|�dd�dS)Ncs�t|��t�|�dS)zNotify and log errors.N)r,r"r2)�err�Znotifyrr�notify_errorYsz-_renew_describe_results.<locals>.notify_errorz;** DRY RUN: simulating 'certbot renew' close to cert expiryz>**          (The test certificates below have not been saved.)rz0The following certs are not due for renewal yet:ZskippedzNo renewals were attempted.zNo hooks were run.zOCongratulations, all renewals succeeded. The following certs have been renewed:ZsuccesszFAll renewal attempts failed. The following certs could not be renewed:Zfailurez.The following certs were successfully renewed:�
z)The following certs could not be renewed:zB
Additionally, the following renewal configurations were invalid: Z	parsefailz>**          (The test certificates above have not been saved.)F)Zwrap)
r@�zope�	component�
getUtilityr	�IDisplayr\rrrrr�notificationrd)r/�renew_successes�renew_failures�
renew_skipped�parse_failures�out�disprurrtr�_renew_describe_resultsRsJ
��
r�cszt�fdd��jD��r"t�d���jr:t���j�g}n
t���}g}g}g}g}tj	�
�od�j}|D�]�}tj
�tj�}|jd|dd�t���}	t�|�}
zt|	|�}WnVtk
�r}z6t�d||
|�t�dt���|�|�WY�qjW5d	}~XYnXz�|d	k�r"|�|�n�tj
�|	�|��d
dlm }
t!j"�#�}t$|	|��r�|�r�t%�&dd
�}t�'d|�t(�)|�d}|
�*|	||�|�|j+�n0t,�-|�.d|�/���}|�d|j+|�0d�f�t1�2|	||�Wqjtk
�r0}z0t�d|
||�t�dt���|�|j+�W5d	}~XYqjXqjt3�||||�|�sP|�rlt�d�4t5|�t5|����n
t�d�d	S)z5Examine each lineage; renew if due and report resultsc3s|]}|�jkVqdS)N)r4)rZdomain�r/rrrp�sz)handle_renewal_request.<locals>.<genexpr>afCurrently, the renew verb is capable of either renewing all installed certificates that are due to be renewed or renewing a single certificate specified by its name. If you would like to renew specific certificates by their domains, use the certonly command instead. The renew verb may provide other options for selecting certificates to renew in the future.zProcessing F)�pausezTRenewal configuration file %s (cert: %s) produced an unexpected error: %s. Skipping.rNr)�main�i�z3Non-interactive renewal: random delay of %s secondsr`z%s expires on %sz%Y-%m-%dzQAttempting to renew cert (%s) from %s produced an unexpected error: %s. Skipping.z*{0} renew failure(s), {1} parse failure(s)zno renewal failures)6�anyr.rr+Zcertnamer
Zrenewal_file_for_certnameZrenewal_conf_files�sys�stdin�isattyZrandom_sleep_on_renewrwrxryr	rzr{�copy�deepcopyZlineagename_for_filenamer3�	Exceptionr"r#r$r%r&r@ZprovideUtilityZensure_deployed�certbotr��
plugins_discoZPluginsRegistryZfind_allr^�randomZuniformrX�time�sleeprlZ	fullchainrZnotAfter�versionrk�strftimerZrun_generic_updatersr�rV�len)r/Z
conf_filesr|r}r~rZapply_random_sleepZrenewal_filer�Zlineage_configZlineagenamer1�er�ZpluginsZ
sleep_timeZexpiryrr�r�handle_renewal_request�s�




�


�
�
��� ��r�)6�__doc__Z
__future__rr�rHZloggingr�r�r�r%rbr8Zzope.componentrwZacme.magic_typingrr�rrrrrr	r
rrZcertbot.compatr
Zcertbot.pluginsrr�Z	getLogger�__name__r"rQrOrLrBrIZCONFIG_ITEMSr3r:r)r(rJrNrPrRr^rgrlrrr�r�rrrr�<module>st
���9+2

Anon7 - 2021