JFIF$        dd7 

Viewing File: /usr/lib/python3.9/site-packages/certbot/_internal/__pycache__/renewal.cpython-39.opt-1.pyc

a

}|�g�e�@sndZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZddlmZddlm
Z
ddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddl$m%Z&ddl'm(Z)ddl*m+Z+ddl,mZ-e�.e/�Z0gd�Z1ddgZ2gd�Z3e4e�5e3e2e1d ��Z6ej7e8ee"j9d!�d"d#�Z:ej7e
e8e	fdd$�d%d&�Z;ej7e
e8e	fdd$�d'd(�Z<ej7e
e8e	fdd$�d)d*�Z=e
e8e	fe
e8e	fd+�d,d-�Z>e8eee8e8fee8d.�d/d0�Z?e8e8e@d1�d2d3�ZAe8e8eBd1�d4d5�ZCe8e8ee8d1�d6d7�ZDej7e"j9e@d8�d9d:�ZEej7e"j9e8dd;�d<d=�ZFej7e"j9dd8�d>d?�ZGej7eee8ejHe"j9dd@�dAdB�ZIee8e8e8dC�dDdE�ZJej7ee8ee8ee8ee8ddF�dGdH�ZKej7eeLeLfdI�dJdK�ZMe8ej7ddL�dMdN�ZNdS)OzGFunctionality for autorenewal and associated juggling of configurations�N)�Any)�Dict)�Iterable)�List)�Mapping)�Optional)�Tuple)�Union)�default_backend)�ec)�rsa)�load_pem_private_key)�
configuration)�crypto_util)�errors)�util)�cli)�client)�	constants)�hooks)�storage)�updater)�obj)�disco)�os)Z
config_dirZlogs_dirZwork_dirZ
user_agent�serverZaccount�
authenticator�	installer�
renew_hook�pre_hook�	post_hookZhttp01_addressZpreferred_chain�key_type�elliptic_curve�rsa_key_size�http01_port)Zmust_stapleZallow_subset_of_names�	reuse_keyZ	autorenew)�pref_challs)�config�	full_path�returnc
Cs~zt�||�}WnXttjfyh}z:t�d|�t�dt|��t�dt	�
��WYd}~dSd}~00d|jvr�t�d|�dS|jd}d|vr�t�d|�dS|�d	d
�|d	<t
|�}zt||�t||�WnPttjf�y&}z0t�d|t|��t�dt	�
��WYd}~dSd}~00zdd
�|��D�|_Wn8tj�yx}zt�d||�WYd}~dSd}~00|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

    z(Renewal configuration file %s is broken.zThe error was: %s
Skipping.�Traceback was:
%sN�
renewalparamsz<Renewal configuration file %s lacks renewalparams. Skipping.rzJRenewal configuration file %s does not specify an authenticator. Skipping.r!rzHAn error occurred while parsing %s. The error was %s. Skipping the file.cSsg|]}t�|��qS�)rZenforce_domain_sanity)�.0�dr,r,�=/usr/lib/python3.9/site-packages/certbot/_internal/renewal.py�
<listcomp>qs�z reconstitute.<locals>.<listcomp>z{Renewal configuration file %s references a certificate that contains an invalid domain name. The problem was: %s. Skipping.)r�
RenewableCert�OSErrorrZCertStorageError�logger�error�str�debug�	traceback�
format_excr�get�"_remove_deprecated_config_elements� restore_required_config_elements�_restore_plugin_configs�
ValueError�Error�names�domainsZConfigurationError)r'r(�renewal_candidater4r+r,r,r/�reconstitute9sP
�
�
���rB)r'r+r)cCsPd|vr|�d�s|d|_d|vrL|�d�sL|d}t|t�rF|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)�set_by_userrC�
isinstancer5rD)r'r+Zwpr,r,r/�_restore_webroot_config|s

rGcCs�g}|ddkrt||�n|�|d�|�d�durF|�|d�t|�D]n}|�dd�}|��D]T\}}|�|d�rf|�|�sf|dvr�t||t	|��qft
�|�}t||||��qfqNdS)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)rG�appendr9�set�replace�items�
startswithrE�setattr�evalrZ
argparse_type)r'r+Zplugin_prefixesZ
plugin_prefixZconfig_itemZconfig_value�castr,r,r/r<�s
r<c
Cs�i}t�dtffttt�t��ttt�t��tt	t�t
���}|D]0\}}||vrB|�|�sB||||�}|||<qB|��D]\}}t
|||�q|dS)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

    r&N)�	itertools�chain�_restore_pref_challs�zip�BOOL_CONFIG_ITEMS�repeat�
_restore_bool�INT_CONFIG_ITEMS�_restore_int�STR_CONFIG_ITEMS�_restore_strrErPrR)r'r+Zupdated_valuesZrequired_itemsZ	item_nameZrestore_func�value�keyr,r,r/r;�s�
r;)r+r)cCsdd�|��D�S)z�Removes deprecated config options from the parsed renewalparams.

    :param dict renewalparams: list of parsed renewalparams

    :returns: list of renewalparams with deprecated config options removed
    :rtype: dict

    cSs i|]\}}|tjvr||�qSr,)rZDEPRECATED_OPTIONS)r-Zoption_name�vr,r,r/�
<dictcomp>�s
�z6_remove_deprecated_config_elements.<locals>.<dictcomp>)rP)r+r,r,r/r:�s	r:)�unused_namer`r)cCst|t�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 a bool

    )rFr5rZparse_preferred_challenges)rdr`r,r,r/rW�srW)�namer`r)cCs.|��}|dvr&t�d|�d|����|dkS)a#Restores a 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 a bool

    )�trueZfalsezExpected True or False for z but found rf)�lowerrr>)rer`Zlowercase_valuer,r,r/r[�sr[cCsV|dkr$|dkr$t�d�t�d�Sz
t|�WStyPt�d|����Yn0dS)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

    r$rJz!updating legacy http01_port valuezExpected a numeric value for N)r3�infor�flag_default�intr=rr>�rer`r,r,r/r]s


r]cCs@|dkr0|tjkr0t�dtjd|�tjdS|dkr<dS|S)z�Restores a 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 %srJN)rZV1_URIr3rhZCLI_DEFAULTSrkr,r,r/r_s
�
r_)r'�lineager)cCsL|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...Tz0Certificate is due for renewal, auto-renewing...zCCertificate not due for renewal, but simulating renewal for dry runz#Certificate not yet due for renewalF)Zrenew_by_defaultr3r6Zshould_autorenewrh�dry_run�display_util�notify)r'rlr,r,r/�should_renew7s



rp)r'rl�original_serverr)cCs@t�|j�r<t�|�s<|js<d�|���}t�d|�d���dS)z9Do not renew a valid cert with one from a staging server!z, z^You've asked to renew/replace a seemingly valid certificate with a test certificate (domains: z@). We will not do that unless you use the --break-my-certs flag!N)rZ
is_stagingrZbreak_my_certs�joinr?rr>)r'rlrqr?r,r,r/�_avoid_invalidating_lineageFs
��rscs���d�r�jsdS�js$�js$dS�jr.dS�j���d��fdd�fd���fdd�fd���fd	d�fg}|D]$}|d
�rtt�d|d�d
���qtdS)z�Don't allow combining --reuse-key with any flags that would conflict
    with key reuse (--key-type, --rsa-key-size, --elliptic-curve), unless
    --new-key is also set.
    r%Nz
--key-typecs��j��kS�N)Zprivate_key_typergr,)�ktrlr,r/�<lambda>n�z,_avoid_reuse_key_conflicts.<locals>.<lambda>z--rsa-key-sizecs�dko�j�jkS)Nr)r#r,�r'rurlr,r/rvprwz--elliptic-curvecs"�dko �jo �j���j��kS)N�ecdsa)r"rgr,rxr,r/rvrs�zUnable to change the rz� of this certificate because --reuse-key is set. To stop reusing the private key, specify --no-reuse-key. To change the private key this one time and then reuse it in future, add --new-key.)rEr%�new_keyr!rgrr>)r'rlZpotential_conflictsZconflictr,rxr/�_avoid_reuse_key_conflictsSs,
����

�r|)r'r@�	le_clientrlr)cCs�|jd}|�dt�d��}t|||�t||�|s>|��}|jrd|jsdt	j
�|j�}t
||�nd}|�||�\}}}}	|jr�t�dt	j
�|j��n2|��}
|�|
||j||�|�|���|��t�|||j�dS)zRenew a certificate lineage.r+rNz(Dry run: skipping updating lineage at %s)rr9rrirsr|r?r%r{r�path�normpathZprivkey�_update_renewal_params_from_keyZobtain_certificatermr3r6�dirname�cert�latest_common_versionZsave_successorZpemZupdate_all_links_to�truncaterrZlive_dir)r'r@r}rlZrenewal_paramsrqr{Znew_certZ	new_chainrIZ
prior_versionr,r,r/�
renew_certs$

r�)�msgs�categoryr)cs �fdd�|D�}dd�|�S)z:Format a results report for a category of renewal outcomesc3s|]}d|�fVqdS)z%s (%s)Nr,)r-�m�r�r,r/�	<genexpr>�rwzreport.<locals>.<genexpr>z  z
  )rr)r�r��linesr,r�r/�report�sr�)r'�renew_successes�renew_failures�
renew_skipped�parse_failuresr)cCs>tj}tj}|dtj���|jr&dnd}|rD|d�|t|d��|s�|s�|d|�d��|jdusz|j	dusz|j
dur�|d	�n�|r�|s�|d
|�d��|t|d��nh|r�|s�|d
|�|t|d��nF|�r|�r|d|�d��|t|d�d�|d|�|t|d��|�r0|d�|t|d��|tj�dS)a�
    Print a report to the terminal about the results of the renewal process.

    :param configuration.NamespaceConfiguration config: Configuration
    :param list renew_successes: list of fullchain paths which were renewed
    :param list renew_failures: list of fullchain paths which failed to be renewed
    :param list renew_skipped: list of messages to print about skipped certificates
    :param list parse_failures: list of renewal parameter paths which had errors
    �
zsimulated renewalZrenewalz7The following certificates are not due for renewal yet:ZskippedzNo zs were attempted.NzNo hooks were run.zCongratulations, all z
s succeeded: �successz@All %ss failed. The following certificates could not be renewed:ZfailurezThe following zs succeeded:zThe following %ss failed:zB
Additionally, the following renewal configurations were invalid: Z	parsefail)rnror3r4�display_objZ
SIDE_FRAMErmr�rrr )r'r�r�r�r�roZnotify_errorZrenewal_nounr,r,r/�_renew_describe_results�s@
��
�
r�)r'r)cs�t�fdd��jD��r"t�d���jr:t���j�g}n
t���}g}g}g}g}g}g}tj	�
�ol�j}|D�]�}	tj
d|	dd�t���}
t�|	�}zt|
|	�}Wn\t�y}
zBt�d|	||
�t�dt���|�|	�WYd	}
~
qrWYd	}
~
n
d	}
~
00z�|�s|�|	�n�|��d
dlm}tj��}t|
|��r�|�rtt �!dd
�}t�"d|�t#�$|�d}|�%|
||�|�|j&�|�'|�(��n0t)�*|�+d|�,���}|�d|j&|�-d�f�t.�/|
||�Wqrt�yB}
zJt�d||
�t�dt���|�r.|�|j&�|�'|�(��WYd	}
~
qrd	}
~
00qrt0�||||�|�sb|�r�t�t1|��dt1|��d���t�d�||fS)z5Examine each lineage; renew if due and report resultsc3s|]}|�jvVqdSrt)rC)r-�domain�r'r,r/r��rwz)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.r*Nr)�mainrzi�z3Non-interactive renewal: random delay of %s secondsr�z%s expires on %sz%Y-%m-%dz-Failed to renew certificate %s with error: %sz renew failure(s), z parse failure(s)zno renewal failures)2�anyr@rr>ZcertnamerZrenewal_file_for_certnameZrenewal_conf_files�sys�stdin�isattyZrandom_sleep_on_renewrnZnotification�copy�deepcopyZlineagename_for_filenamerB�	Exceptionr3r4r6r7r8rMZensure_deployed�certbot._internalr��
plugins_discoZPluginsRegistryZfind_allrp�randomZuniformrh�time�sleepr�Z	fullchain�extendr?rZnotAfter�versionr��strftimerZrun_generic_updatersr��len)r'Z
conf_filesr�r�r�r�Zrenewed_domainsZfailed_domainsZapply_random_sleepZrenewal_fileZlineage_configZlineagenamerA�er�ZpluginsZ
sleep_timeZexpiryr,r�r/�handle_renewal_request�s�




�
"
�
�
���&��
r�)�key_pathr'r)cCs�t|d��$}t|��dt�d�}Wd�n1s40Yt|tj�rZd|_|j|_	n:t|t
j�rxd|_|jj
|_nt�d|�dt|��d���dS)N�rb)�passwordZbackendrryzKey at z is of an unsupported type: �.)�openr
�readr
rFrZ
RSAPrivateKeyr!Zkey_sizer#rZEllipticCurvePrivateKeyZcurverer"rr>�type)r�r'Zfile_hrar,r,r/r�@s2
r�)O�__doc__r�rUZloggingr�r�r�r7�typingrrrrrrrr	Zcryptography.hazmat.backendsr
Z)cryptography.hazmat.primitives.asymmetricrrZ,cryptography.hazmat.primitives.serializationr
Zcertbotrrrrr�rrrrrrZcertbot._internal.displayrr�Zcertbot._internal.pluginsrr�Zcertbot.compatrZcertbot.displayrnZ	getLogger�__name__r3r^r\rYrNrVZCONFIG_ITEMSZNamespaceConfigr5r1rBrGr<r;r:rW�boolr[rjr]r_rprsr|ZClientr�r�r��listr�r�r,r,r,r/�<module>s�
�
�C��,� 
"�
�,
�
�0n
Back to Directory  nL+D550H?Mx ,D"v]qv;6*Zqn)ZP0!1 A "#a$2Qr D8 a Ri[f\mIykIw0cuFcRı?lO7к_f˓[C$殷WF<_W ԣsKcëIzyQy/_LKℂ;C",pFA:/]=H  ~,ls/9ć:[=/#f;)x{ٛEQ )~ =𘙲r*2~ a _V=' kumFD}KYYC)({ *g&f`툪ry`=^cJ.I](*`wq1dđ#̩͑0;H]u搂@:~וKL Nsh}OIR*8:2 !lDJVo(3=M(zȰ+i*NAr6KnSl)!JJӁ* %݉?|D}d5:eP0R;{$X'xF@.ÊB {,WJuQɲ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