File: //usr/lib/python3/dist-packages/certbot/_internal/__pycache__/renewal.cpython-310.pyc
o
6��a�Y � @ sZ d Z ddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm
Z
ddlmZ ddl
mZ ddl
mZ ddlmZ ddlZdd lmZ dd
lmZ ddlmZ ddlmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z ddl!m"Z# ddl$m%Z& ddl'm(Z( dd
l)mZ* e�+e,�Z-g d�Z.ddgZ/g d�Z0e1e�2e0e/e.d��Z3dd� Z4dd� Z5d d!� Z6d"d#� Z7d$d%� Z8d&d'� Z9d(d)� Z:d*d+� Z;d,d-� Z<d.d/� Z=d0d1� Z>d2ej?d3e
e e@ d4ejAd5ejBd6df
d7d8�ZCd9d:� ZDd2ej?d;e e@ d<e e@ d=e e@ d>e e@ d6dfd?d@�ZEdAdB� ZFdCe@d2ej?d6dfdDdE�ZGdS )FzGFunctionality for autorenewal and associated juggling of configurations� N)�List)�Optional)�default_backend)�ec)�rsa)�load_pem_private_key)�
configuration)�crypto_util)�errors)�
interfaces)�util)�cli)�client)� constants)�hooks)�storage)�updater)�obj)�disco)�os)�
config_dir�logs_dir�work_dir�
user_agent�server�account�
authenticator� installer�
renew_hook�pre_hook� post_hook�http01_address�preferred_chain�key_type�elliptic_curve�rsa_key_size�http01_port)�must_staple�allow_subset_of_names� reuse_key� autorenew)�pref_challsc
C sh zt �|| �}W n, tjtfy4 } zt�d|� t�dt|�� t�dt �
� � W Y d}~dS d}~ww d|jvrBt�d|� dS |jd }d|vrSt�d|� dS t|�}zt
| |� t| |� W n' ttjfy� } zt�d |t|�� t�dt �
� � W Y d}~dS d}~ww z
d
d� |�� D �| _W |S tjy� } zt�d||� W Y d}~dS d}~ww )
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.r zJRenewal configuration file %s does not specify an authenticator. Skipping.zHAn error occurred while parsing %s. The error was %s. Skipping the file.c S s g | ]}t �|��qS � )r �enforce_domain_sanity)�.0�dr. r. �;/usr/lib/python3/dist-packages/certbot/_internal/renewal.py�
<listcomp>d s �z!_reconstitute.<locals>.<listcomp>z{Renewal configuration file %s references a certificate that contains an invalid domain name. The problem was: %s. Skipping.)r �
RenewableCertr
�CertStorageError�IOError�logger�error�str�debug� traceback�
format_excr �"_remove_deprecated_config_elements� restore_required_config_elements�_restore_plugin_configs�
ValueError�Error�names�domains�ConfigurationError)�config� full_path�renewal_candidater8 r- r. r. r2 �
_reconstitute5 sZ ��
�
�
���
�����rH c C sX d|v rt �d�s|d | _d|v r(t �d�s*|d }t|t�r#|g}|| _dS dS 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_clirI �
isinstancer9 rJ )rE r- �wpr. r. r2 �_restore_webroot_configo s
�rN c C s� g }|d dkrt | |� n|�|d � |�d�dur#|�|d � t|�D ]7}|�dd�}|�� D ]*\}}|�|d �r]t�|�s]|dv rPt | |t
|�� q3t�|�}t | |||�� q3q'dS )a Sets 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 �webrootr N�-�_)�None�True�False)rN �append�get�set�replace�items�
startswithr
rK �setattr�eval�
argparse_type)rE r- �plugin_prefixes�
plugin_prefix�config_item�config_value�castr. r. r2 r? � s"