%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/certbot/_internal/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/certbot/_internal/__pycache__/client.cpython-312.pyc

�

M/�eo����dZddlZddlZddlZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZdd
lmZddl
mZddlmZddlZdd
lmZddlmZddlmZddlmZddlZddlmZddlmZddlmZddlmZddl Z ddl m!Z!ddl mZddl mZddl m"Z"ddl m#Z#ddl$m%Z%ddl$m&Z&ddl$m'Z'ddl$m(Z(ddl$m)Z)ddl$m*Z*ddl$m+Z+ddl,m-Z.dd l,m/Z0dd!l1m2Z2dd"l3m4Z5ddl3m#Z6dd#l7m8Z8ejre:�Z;	dBd$e!jxd%ejzd&eej|d'ej~fd(�Z@d$e!jxd'eAfd)�ZBd$e!jxd'eAfd*�ZCGd+�d,�ZDd'eAfd-�ZE	dBd$e!jxd.e8d/eeeAgdfd'ee%j�ej~ffd0�ZGd1ej~d$e!jxd/eeeAgdfd'ej|fd2�ZHGd3�d4�ZIdBd5e#j�d6ee#j�d'dfd7�ZLd8eAd9eMd$e!jxd:e.j�d'df
d;�ZOd$e!jxd<eAd=eAd'ee	eAffd>�ZPd?eQd@e	d'dfdA�ZRy)CzCertbot client API.�N)�Any)�Callable)�cast)�Dict)�IO)�List)�Optional)�Tuple)�default_backend)�generate_private_key)�ES256)�ES384)�ES512)�RS256)�client)�crypto_util)�errors)�messages)�
configuration)�
interfaces)�util)�account)�auth_handler)�cli)�	constants)�eff)�
error_handler)�storage)�disco)�	selection)�os)�ops)�AccountStorage�config�key�regr�returnc	���|jdk(rc|j}|jdk(rt}nG|jdk(rt}n1|jdk(rt
}nt
jd��t}tj||||jt|���}tjj|j|�}tj||�S)z Wrangle ACME client construction�EC�i�i	z6No matching signing algorithm can be found for the key)�algr�
verify_ssl�
user_agent)�typr%�key_sizer
rrr�NotSupportedErrorr�acme_client�
ClientNetwork�
no_verify_ssl�determine_user_agent�ClientV2�
get_directory�server)r$r%r&�
public_keyr+�net�	directorys       �:/usr/lib/python3/dist-packages/certbot/_internal/client.py�acme_from_config_keyr<2s����w�w�$���W�W�
����#�%��C�
�
 �
 �C�
'��C�
�
 �
 �C�
'��C��*�*�H��
���
�
#�
#�C�S�$�4:�4H�4H�0H�/C�F�/K�M�C��$�$�2�2�6�=�=�#�F�I����	�3�/�/�c���|j��d}tjjd�dk(rd}d}d}n8tj
}t
j�}tj�}|jtj|||j|j|jt!|�||j"rd|j"z�	}|Sd�	}|S|j}|S)	z�
    Set a user_agent string in the config based on the choice of plugins.
    (this wasn't knowable at construction time)

    :returns: the client's User-Agent string
    :rtype: `str`
    z\CertbotACMEClient/{0} ({1}; {2}{8}) Authenticator/{3} Installer/{4} ({5}; flags: {6}) Py/{7}�CERTBOT_DOCS�1�certbotzOS_NAME OS_VERSIONzmajor.minor.patchlevelz; �)r-r!�environ�getr�cli_commandr�get_os_info_ua�platform�python_version�formatrA�__version__�
authenticator�	installer�verb�ua_flags�user_agent_comment)r$�uarE�os_inforHs     r;r4r4Ls������ �)��
�:�:�>�>�.�)�S�0�#�K�*�G�5�N��/�/�K��)�)�+�G�%�4�4�6�N�
�Y�Y�w�*�*�K���+�+�V�-=�-=�v�{�{���'��;A�;T�;T�t�f�7�7�7�^���I�[]�^���I��
�
��
�Ir=c��t|t�ryg}|jr|jd�|jr|jd�|j
r|jd�|jr|jd�d}|D�cgc]}t||dz���}}t|�r|jd�d	j|�Scc}w)
z@Turn some very important CLI flags into clues in the user agent.�FLAGS�dup�frn�asn�n)�pre�post�renew�manual_auth�manual_cleanup�_hook�hook� )
�
isinstance�DummyConfig�	duplicate�append�renew_by_default�allow_subset_of_names�noninteractive_mode�getattr�any�join)r$�flags�
hook_names�h�hookss     r;rNrNls����&�+�&���E�
���
���U��
���
���U��
�#�#�
���U��
�!�!�
���S��J�J�3=�>�a�W�V�Q��[�
)�>�E�>�
�5�z�
���V���8�8�E�?���
?s�Cc�(�eZdZdZdd�Zdedefd�Zy)raz'Shim for computing a sample user agent.r'Nc�<�d|_d|_d|_d|_y)N�XXX�YYY�
SUBCOMMAND)rKrLr-rM)�selfs r;�__init__zDummyConfig.__init__�s��"��������� ��	r=�namec��y)z-Any config properties we might have are None.N��rsrus  r;�__getattr__zDummyConfig.__getattr__�s��r=)r'N)�__name__�
__module__�__qualname__�__doc__rt�strrryrwr=r;rara�s��1�!�����r=rac�X�tttjt	���S)z<Document what this Certbot's user agent string will be like.)r4rr�NamespaceConfigrarwr=r;�sample_user_agentr��s�� ��]�%B�%B�K�M� R�S�Sr=�account_storage�tos_cbc��|j�r tjd|j�|j�Y|j
s,d}tj
|�tj|��|jstjd�|jrd|_td|jt���}tjtj |���}t#||�}t%|||�}t'j(||�}|j+||�t-j.||�||fS)a�Register new account with an ACME CA.

    This function takes care of generating fresh private key,
    registering the account, optionally accepting CA Terms of Service
    and finally saving the account. It should be called prior to
    initialization of `Client`, unless account has already been created.

    :param certbot.configuration.NamespaceConfig config: Client configuration.

    :param .AccountStorage account_storage: Account storage where newly
        registered account will be saved to. Save happens only after TOS
        acceptance step, so any account private keys or
        `.RegistrationResource` will not be persisted if `tos_cb`
        returns ``False``.

    :param tos_cb: If ACME CA requires the user to accept a Terms of
        Service before registering account, client action is
        necessary. For example, a CLI tool would prompt the user
        acceptance. `tos_cb` must be a callable that should accept
        a Term of Service URL as a string, and raise an exception
        if the TOS is not accepted by the client. ``tos_cb`` will be
        called only if the client action is necessary, i.e. when
        ``terms_of_service is not None``. This argument is optional,
        if not supplied it will default to automatic acceptance!

    :raises certbot.errors.Error: In case of any client problems, in
        particular registration failure, or unaccepted Terms of Service.
    :raises acme.errors.Error: In case of any protocol problems.

    :returns: Newly registered and saved account, as well as protocol
        API handle (should be used in `Client` initialization).
    :rtype: `tuple` of `.Account` and `acme.client.Client`

    z*There are already existing accounts for %sNzLNo email was provided and --register-unsafely-without-email was not present.zRegistering without email!i)�public_exponentr/�backend)r%)�find_all�logger�infor7�email�register_unsafely_without_email�errorr�Error�dry_run�debugr�rsa_key_sizer�jose�JWKRSA�ComparableRSAKeyr<�perform_registrationr�Account�saver�prepare_subscription)	r$r�r��msg�rsa_keyr%�acmer&�accs	         r;�registerr��s��L���!����@�&�-�-�P�
�|�|���5�5�H�C��L�L����,�,�s�#�#��~�~��L�L�5�6��~�~����#�!��(�(�#�%�'�G��+�+�$�/�/��8�
9�C����,�D���f�f�5�D�
�/�/�$��
$�C�����d�#����V�S�)���9�r=r�c�<�|jxr|j}|rf|jjj	�}t
jj||j|j|j��}nd}|j�r|sd}tj|��|jjj}|r
|r||�	|jt
jj|j d|���S#t
j$rr}|j"dvr^|j$r%d|j �d�}tj|��t'j(d�	�|_t+|||�cYd}~S�d}~wwxYw)
a�
    Actually register new account, trying repeatedly if there are email
    problems

    :param acme.client.Client acme: ACME client object.
    :param certbot.configuration.NamespaceConfig config: Client configuration.
    :param Callable tos_cb: a callback to handle Term of Service agreement.

    :returns: Registration Resource.
    :rtype: `acme.messages.RegistrationResource`
    )�account_public_key�kid�hmac_keyr:NzRServer requires external account binding. Please use --eab-kid and --eab-hmac-key.T)r��terms_of_service_agreed�external_account_binding)�invalidEmail�invalidContactzThe ACME server believes z_ is an invalid email address. Please ensure it is a valid email and attempt registration again.)�invalid)�eab_kid�eab_hmac_keyr9r%r8r�ExternalAccountBinding�	from_datar:�external_account_requiredrr��meta�terms_of_service�new_account�NewRegistrationr��coderf�display_ops�	get_emailr�)	r�r$r��eab_credentials_suppliedr��eabr��tos�es	         r;r�r��sm�� &�~�~�E�&�2E�2E���!�X�X�\�\�4�4�6���-�-�7�7�K]�<B�N�N�AG�AT�AT�BF�.�.�8�R��
���%�%�'�'�?�C��,�,�s�#�#�
�.�.�
�
�
.�
.�C�
�#��s������� 8� 8� B� B��l�l�D�[^�!C�!`�a�	a���>�>�	��6�6�7�7��)�)�2�6�<�<�.�A-�-���l�l�3�'�'�&�0�0��>�F�L�'��f�f�=�=�
��	�s%�:D�F�)A&F�F�F�Fc�6�eZdZdZ	d,dej
deejdee	jdee	jdeejddfd	�Z	d,d
ej deej$deeeffd�Zd,d
eedeedeeeej0ej ffd�Zdededej$fd�Zd
eedeedeej:fd�Zdej>d
eedeefd�Z d
eedeedeeeej0ej ffd�Z!d
eedeedefd�Z"dedefd�Z#dedededed edeeeeffd!�Z$d
eed"ededed eddfd#�Z%	d-d
eeded$eddfd%�Z&	d,d
eed&ed'eeddfd(�Z'd)eeddfd*�Z(d)eddfd+�Z)y).�ClientawCertbot's client.

    :ivar certbot.configuration.NamespaceConfig config: Client configuration.
    :ivar .Account account: Account registered with `register`.
    :ivar .AuthHandler auth_handler: Authorizations handler that will
        dispatch DV challenges to appropriate authenticators
        (providing `.Authenticator` interface).
    :ivar .Authenticator auth: Prepared (`.Authenticator.prepare`)
        authenticator that can solve ACME challenges.
    :ivar .Installer installer: Installer.
    :ivar acme.client.ClientV2 acme: Optional ACME client API handle. You might
        already have one from `register`.

    Nr$�account_�authrLr�r'c�r�||_||_||_||_|�A|j�5t	||jj
|jj�}||_||�Ftj||j|j|jj�|_yd|_y)zInitialize a client.N)r$rr�rLr<r%r&r�r�AuthHandler�pref_challs)rsr$r�r�rLr�s      r;rtzClient.__init__s���
��������	�"����<�D�L�L�4�'�����0@�0@�$�,�,�BS�BS�T�D���	���� ,� 8� 8��d�i�i����t�{�{�/F�/F�!H�D��!%�D�r=�csr�orderrc��|j�,d}tj|�tj|��|j
�|j
j�tjd��|j�tjd��tjd|�|�|j|jd��}tjj�tj|jj��z}tjd	|�|jj!|||jj"du�
�}|j$}|jj"rZ|j&rNt)j*|g|j&z|jj"|jj,�}t)j.|�\}}|j1�|j1�fS)aWObtain certificate.

        :param .util.CSR csr: PEM-encoded Certificate Signing
            Request. The key used to generate this CSR can be different
            than `authkey`.
        :param acme.messages.OrderResource orderr: contains authzrs

        :returns: certificate and chain as PEM byte strings
        :rtype: tuple

        Nz>Unable to obtain certificate because authenticator is not set.z+Please register with the ACME server first.�ACME client is not set.zCSR: %sF)�best_effort)�secondsz+Will poll for certificate issuance until %s)�fetch_alternative_chains)rr�r�rr�rr&r�r��_get_order_and_authorizations�data�datetime�now�	timedeltar$�issuance_timeout�finalize_order�preferred_chain�
fullchain_pem�alternative_fullchains_pemr�find_chain_with_issuerr��cert_and_chain_from_fullchain�encode)rsr�r�r��deadline�	fullchain�cert�chains        r;�obtain_certificate_from_csrz"Client.obtain_certificate_from_csr3s������$��C��L�L����,�,�s�#�#��<�<��4�<�<�#4�#4�#<��,�,�L�M�M��9�9���,�,�8�9�9����Y��$��>��7�7����e�7�T�F��$�$�(�(�*�X�-?�-?��K�K�0�0�.2�2��	���B�H�M����)�)��H�t�{�{�7R�7R�Z^�7^�*�`���(�(�	��;�;�&�&�6�+L�+L�#�:�:���f�?�?�?����+�+����1D�1D�-D�F�I�"�?�?�	�J���e��{�{�}�e�l�l�n�,�,r=�domains�old_keypathc	���|�Ut|d�5}|}|j�}ddd�tj��}tjd|�nd}|jj}d}t|jjt�r(|jjd|j_	|jjrc|jjdk(rJ|jj}d|j_d	|j_
d
|j_nS|jjr=|jjj�dk(r|jj}|jj r�|xsAtjdt#j$|||jj����}tj&dd
t)j*|j,||jj.���}	n�|xsBt#j0|d|jj||jj2��}t#j4||d|jj.|jj2�}		|j7|	j8|jj:�}
|
jF}
|
D�chc]"}|jHjJjL��$}}|D�cgc]	}||vs�|��}}|jj:r||k7r|jE||�S	|jO|	|
�\}}||||	fS#1swY��_xYw#t<j>$rX}|jj:r<|jA||�}||k7r%tC|�dk7r|jE||�cYd}~S�d}~wwxYwcc}wcc}w#t<j>$rX}|jj:r<|jA||�}||k7r%tC|�dk7r|jE||�cYd}~S�d}~wwxYw)a�Obtains a certificate from the ACME server.

        `.register` must be called before `.obtain_certificate`

        :param list domains: domains to get a certificate

        :returns: certificate as PEM string, chain as PEM string,
            newly generated private key (`.util.Key`), and DER-encoded
            Certificate Signing Request (`.util.CSR`).
        :rtype: tuple

        N�rb)�file�pemz%Reusing existing private key from %s.�	secp256r1r�ecdsaz./chain-ecdsa.pemz./cert-ecdsa.pemz./key-ecdsa.pem�rsa)�bits�elliptic_curve�key_typer�)r��formr�)r/�key_dirr�r��strict_permissions)(�open�readr�Keyr�r�r$r�r`r��listr��auth_chain_path�auth_cert_path�key_path�lowerr�r�make_key�CSR�acme_crypto_util�make_csrr��must_staple�generate_keyr��generate_csrr�r�rerr��_successful_domains_from_error�len�_retry_obtain_certificate�authorizations�body�
identifier�valuer�)rsr�r��f�keypath�keypemr%r/r�r�r�r��successful_domains�authzr�a�auth_domains�dr�r�s                   r;�obtain_certificatezClient.obtain_certificate`s���(�"��k�4�(�
"�A�%�������
"�'+�h�h�G��&H�C��K�K�?��M��C��;�;�+�+��$���d�k�k�*�*�D�1�#'�;�;�#7�#7��#:�D�K�K� ��;�;�%�%�$�+�+�*>�*>�'�*I�!�[�[�7�7�N�*=�D�K�K�'�);�D�K�K�&�#4�D�K�K� �
�[�[�
%�
%�$�+�+�*>�*>�*D�*D�*F�%�*O��{�{�/�/�H��;�;����������(�(�!�#1�!�[�[�1�1���C��(�(��5� 0� 9� 9�"�w�w�����1H�1H�!J�K�C����1�1�!�����-�-�-�#'�;�;�#A�#A��C��*�*��W�d�D�K�K�$;�$;�T�[�[�=[�=[�]�C�
	��7�7����$�+�+�Bc�Bc�d�F��&�&��9?�@�A����)�)�/�/�@��@�)0�F�A�A��4E�a�F��F��;�;�,�,�1C�w�1N��1�1�'�;M�N�N�
�"�>�>�s�F�K���e��U�C��,�,�S
"�
"��d�~�~�	��{�{�0�0�%)�%H�%H��PW�%X�"�%��0�S�9K�5L�PQ�5Q��9�9�'�CU�V�V���	��A��F���>�>�
��;�;�4�4�)-�)L�)L�U�T[�)\�&�)�W�4��=O�9P�TU�9U�#�=�=�g�GY�Z�Z���
�sg�M?�90N�9'O:�&	O?�0O?�$P�?N	�O7�AO2�+O7�1O2�2O7�Q/�AQ*�#Q/�)Q*�*Q/�csr_pemr�c��|jstjd��	|jj|�}|jstjd��|r}|jjrg|jj|�\}}|r0tjd�|jj|�}|rtjd�|jj||j|�}|j|��S#tj
$rtjd��wxYw)abRequest a new order and complete its authorizations.

        :param bytes csr_pem: A CSR in PEM format.
        :param bool best_effort: True if failing to complete all
            authorizations should not raise an exception

        :returns: order resource containing its completed authorizations
        :rtype: acme.messages.OrderResource

        r�zWThe currently selected ACME CA endpoint does not support issuing wildcard certificates.z&No authorization handler has been set.z*Recreating order after authz deactivationszCertbot was unable to obtain fresh authorizations for every domain. The dry run will continue, but results may not be accurate.)r�)r�rr��	new_order�acme_errors�WildcardUnsupportedErrorrr$r��deactivate_valid_authorizationsr�r��warning�handle_authorizations�update)rsrr�r��deactivated�failedr�s       r;r�z$Client._get_order_and_authorizations�s���y�y��,�,�8�9�9�	N��Y�Y�(�(��1�F�
� � ��,�,�G�H�H��d�k�k�)�)�"&�"3�"3�"S�"S�TZ�"[��K������I�J����,�,�W�5������ _�`��"�"�8�8�����k�Z���}�}�F�}�3�3��%�3�3�	N��,�,� M�N�
N�	N�s�D�)E�certnamec���|j||�}|j|�\}}}}|jjtj
dk7s*|jjtj
dk7rtjd�|jjrtjd|�ytjj|||j||j�S)aFObtain and enroll certificate.

        Get a new certificate for the specified domains using the specified
        authenticator and installer, and then create a new renewable lineage
        containing it.

        :param domains: domains to request a certificate for
        :type domains: `list` of `str`
        :param certname: requested name of lineage
        :type certname: `str` or `None`

        :returns: A new :class:`certbot._internal.storage.RenewableCert` instance
            referred to the enrolled cert lineage, or None if doing a successful dry run.

        �
config_dir�work_dirzdNon-standard path(s), might not work with crontab installed by your operating system package managerz-Dry run: Skipping creating new lineage for %sN)�_choose_lineagenamerr$rr�CLI_DEFAULTSrr�r�r�r�r�
RenewableCert�new_lineager�)rsr�r�new_namer�r�r%�_s        r;�obtain_and_enroll_certificatez$Client.obtain_and_enroll_certificate�s���"�+�+�G�X�>��"�5�5�g�>���e�S�!��K�K�"�"�i�&<�&<�\�&J�J����$�$�	�(>�(>�z�(J�J��K�K�;�
<��;�;����L�L�H�(�S���$�$�0�0��d��G�G�U��K�K��	r=r�c���|j�O|jD�cgc]$}|j�|jj��&}}|D�cgc]	}||vs�|��}}|SgScc}wcc}w�N)�subproblemsr�r�)rsr�r��problem�failed_domains�xr�s       r;r�z%Client._successful_domains_from_errorsz�����(�FK�FW�FW�C�7�#*�#5�#5�#A�&�0�0�6�6�C�N�C�-4�!P����8O�!�!P��!P�%�%��	��	C��!Ps�)A�
	A#�A#r�c��|D�cgc]	}||vs�|��}}dj|�}tjd|���|j|�Scc}w)Nz, zNUnable to obtain a certificate with every requested domain. Retrying without: )ri�display_util�notifyr)rsr�r�rr�domains_lists      r;r�z Client._retry_obtain_certificates`��%,�L���9K�0K�!�L��L��y�y��0�����)�)5��8�	9��&�&�'9�:�:��	Ms
�	A�Ac��d}|r|}n&tj|d�r	|ddd}n|d}|j|�r|Stj|rd��d��)auChooses a name for the new lineage.

        :param domains: domains in certificate request
        :type domains: `list` of `str`
        :param certname: requested name of lineage
        :type certname: `str` or `None`

        :returns: lineage name that should be used
        :rtype: str

        :raises errors.Error: If the chosen lineage name is invalid.

        Nr�zzThe provided certname cannot be used as a lineage name because it contains an illegal character (i.e. filepath separator).z�Cannot use domain name as lineage name because it contains an illegal character (i.e. filepath separator). Specify an explicit lineage name with --cert-name.)r�is_wildcard_domain�_is_valid_lineagenamerr�)rsr�r�lineagenames    r;rzClient._choose_lineagename&sx�����"�K�
�
$�
$�W�Q�Z�
0�!�!�*�Q�R�.�K�!�!�*�K��%�%�k�2����,�,�EM�B�%�
%�$�%�
%r=ruc�:�tjj|vS)aNDetermines whether the provided name is a valid lineagename. A lineagename
        is invalid when it contains filepath separators.

        :param name: the lineage name to determine validity for
        :type name: `str`

        :returns: Whether the provided string constitutes a valid lineage name.
        :rtype: bool

        )r!�path�seprxs  r;r'zClient._is_valid_lineagenameHs���w�w�{�{�$�&�&r=�cert_pem�	chain_pem�	cert_path�
chain_path�fullchain_pathc���|||fD]J}tjtjj	|�d|j
j��Lt|j
d|�\}}	|j|�|j�t|j
d|�\}	}
t|j
d|�\}}t||	�t||z|�||
|fS#|j�wxYw)a$Saves the certificate received from the ACME server.

        :param bytes cert_pem:
        :param bytes chain_pem:
        :param str cert_path: Candidate path to a certificate.
        :param str chain_path: Candidate path to a certificate chain.
        :param str fullchain_path: Candidate path to a full cert chain.

        :returns: cert_path, chain_path, and fullchain_path as absolute
            paths to the actual files
        :rtype: `tuple` of `str`

        :raises IOError: If unable to find room to write the cert files

        i�r.r/r0)r�make_or_verify_dirr!r*�dirnamer$r��_open_pem_file�write�close�_save_chain)
rsr,r-r.r/r0r*�	cert_file�
abs_cert_path�
chain_file�abs_chain_path�fullchain_file�abs_fullchain_paths
             r;�save_certificatezClient.save_certificateUs���$�z�>�9�	b�D��#�#�B�G�G�O�O�D�$9�5�$�+�+�B`�B`�a�	b�$2�$�+�+�{�I�#V� �	�=�	��O�O�H�%��O�O��%3�D�K�K��z�%Z�"�
�N�-;��K�K�)�>�.;�*��*�	�I�z�*��H�y�(�.�9��n�.@�@�@��
�O�O��s�.C#�#C5�privkey_pathc	��|j�*tjd�tjd��|�dnt
jj|�}tjd�d}tj|j|�5|D]v}|jj|t
jj|�t
jj|�||��|jj��x|jjd�ddd�d}tj|j|�5|jj!�ddd�y#1swY�OxYw#1swYyxYw)	abInstall certificate

        :param list domains: list of domains to install the certificate
        :param str privkey_path: path to certificate private key
        :param str cert_path: certificate file path (optional)
        :param str fullchain_path: path to the full chain of the certificate
        :param str chain_path: chain file path

        NzANo installer specified, client is unable to deploythe certificate�No installer availablezDeploying certificatezCould not install certificate)�domainr.r�r/r0zDeployed ACME CertificatezuWe were unable to install your certificate, however, we successfully restored your server to its prior configuration.)rLr�r�rr�r!r*�abspathr!r"r�ErrorHandler�_recovery_routine_with_msg�deploy_certr��_rollback_and_restart�restart)rsr�r?r.r/r0r��doms        r;�deploy_certificatezClient.deploy_certificatezsE���>�>�!��L�L�-�
.��,�,�7�8�8�'�/�T�R�W�W�_�_�Z�5P�
����3�4�-��
�
'�
'��(G�(G��
M�		=��
&�����*�*��"�'�'�/�/�)�*D��W�W�_�_�\�:�)�#1�	+�3�
���#�#�%�

&�
�N�N��� ;�<�		=�4���
'�
'��(B�(B�C�
H�	%��N�N�"�"�$�	%�	%�		=�		=��	%�	%�s�BE6�F�6E?�F�redirect_defaultc�"�|j�*tjd�tjd��d}dddd|fd	f}|jj�}|D][\}}}	t
|j|�}
||vr"|d
k(r|
�|}
|
s�-|j|||	�d}�C|
s�Ftjd|��]d
}|rDtj|j|�5|jj�ddd�yy#1swYyxYw)afEnhance the configuration.

        :param list domains: list of domains to configure
        :param chain_path: chain file path
        :type chain_path: `str` or `None`
        :param redirect_default: boolean value that the "redirect" flag should default to

        :raises .errors.Error: if no installer is specified in the
            client.

        NzDNo installer is specified, there isn't any configuration to enhance.rAF)�hsts�ensure-http-headerzStrict-Transport-Security)�redirectrON�staplezstaple-ocsp)�uirrNzUpgrade-Insecure-RequestsrOTzKOption %s is not supported by the selected installer. Skipping enhancement.z$We were unable to restart web server)
rLr�r�rr��supported_enhancementsrgr$�apply_enhancementrrDrGrH)rsr�r/rK�enhanced�enhancement_info�	supported�config_name�enhancement_name�option�config_valuer�s            r;�enhance_configzClient.enhance_config�s&���>�>�!��L�L�7�
8��,�,�7�8�8���G�*�
�}�j�1�F�	I��
�N�N�9�9�;�	�5E�	:�1�K�)�6�"�4�;�;��<�L��9�,��*�,��1E�#3�L���*�*�7�4D�f�M�#�H�����,�-8�:�	:�5����+�+�D�,F�,F��L�
)����&�&�(�
)�
)��
)�
)�s� D�D�enhancement�optionsc��|jstjd��|dk(r|n|}tj|j
d�5|D] }	|jj
|||��"|jjd|���ddd�y#tj$rtjd|�Y�utj$rtjd||��wxYw#1swYyxYw)a�Applies an enhancement on all domains.

        :param list domains: list of ssl_vhosts (as strings)
        :param str enhancement: name of enhancement, e.g. ensure-http-header
        :param str options: options to enhancement, e.g. Strict-Transport-Security

            .. note:: When more `options` are needed, make options a list.

        :raises .errors.PluginError: If Enhancement is not supported, or if
            there is any other problem with the enhancement.


        z!No installer plugin has been set.rNNzEnhancement %s was already set.z(Unable to set the %s enhancement for %s.zAdd enhancement )
rLrr�rrDrE�enhance�PluginEnhancementAlreadyPresentr�r��PluginErrorr�r�)rsr�r\r]�	enh_labelrIs      r;rSzClient.apply_enhancement�s����~�~��,�,�B�C�C�*�.B�B�G��	�
�
'�
'��(G�(G��
N�
	@��
����N�N�*�*�3��W�E�
�
�N�N���"2�9�+� >�?�
	@�
	@���=�=�N��K�K� A�9�M��)�)���L�L�!K�Y�X[�\����
	@�
	@�s0�C1�B�/ C1�)C.�C1�+C.�.C1�1C:�success_msgc��|jr3|jj�|rtj|�yyy)z�Calls the installer's recovery routine and prints success_msg

        :param str success_msg: message to show on successful recovery

        N)rL�recovery_routiner!r"�rsrcs  r;rEz!Client._recovery_routine_with_msg�s6���>�>��N�N�+�+�-���#�#�K�0��r=c��|jr`tjd�	|jj�|jj	�t
j|�yy#tjd��xYw)z�Rollback the most recent checkpoint and restart the webserver

        :param str success_msg: message to show on successful rollback

        z0Rolling back to previous server configuration...z�An error occurred and we failed to restore your config and restart your server. Please post to https://community.letsencrypt.org/c/help with details about your configuration and this error you received.N)rLr�r��rollback_checkpointsrHr�r!r"rfs  r;rGzClient._rollback_and_restart�sp���>�>��K�K�J�K�

����3�3�5����&�&�(�
����,���

����Y���s�4A.�.Br)T)*rzr{r|r}rr�r	rr�r�
Authenticator�	Installerr1r5rtrr�r�
OrderResourcer
�bytesr�rr~r�r�boolr�rrrr�r�r�rr'r>rJr[rSrErGrwr=r;r�r�
s���
�$9=�%�}�<�<�%��QX�Q`�Q`�Ha�%��
� 8� 8�9�%�$�Z�%9�%9�:�%� �� 4� 4�5�%�BF�%�.PT�+-�t�x�x�+-�,4�X�5K�5K�,L�+-�).�u�e�|�)<�+-�Zm�$�s�)�m�(�3�-�m� %�e�U�D�H�H�d�h�h�&F� G�m�^"4�U�"4�37�"4�<D�<R�<R�"4�H �T�#�Y� �(�SV�-� �+3�G�4I�4I�+J� �D�H�N�N��T�RU�Y��%)�#�Y��;��c��;�PT�UX�PY�;�%*�5�%����4�8�8�+K�%L�;� %�4��9� %���
� %�RU� %�D'�#�'�$�'�#A��#A�5�#A�$'�#A�58�#A�JM�#A�#�C��c�M�2�#A�J%%�$�s�)�%%�3�%%�SV�%%�'*�%%�<?�%%�DH�%%�P15�*)�d�3�i�*)�S�*)�)-�*)�9=�*)�Z48�@��c��@��@�#+�C�=�@�<@�@�<	1�h�s�m�	1��	1�-��-��-r=r��privkeyr�c��|jr4tj|j�stjd��|�rD|j
dk(r�tjjtjj|j�}tjjtjj|�}tj|j|d�}|jr4tj |j�stjd��|jrM|jr@tj"|j|j�stjd��yyyy)a�Validate Key and CSR files.

    Verifies that the client key and csr arguments are valid and correspond to
    one another. This does not currently check the names in the CSR due to
    the inability to read SANs from CSRs in python crypto libraries.

    If csr is left as None, only the key will be validated.

    :param privkey: Key associated with CSR
    :type privkey: :class:`certbot.util.Key`

    :param .util.CSR csr: CSR

    :raises .errors.Error: when validation fails

    z#The provided key is not a valid key�derr�z#The provided CSR is not a valid CSRzThe key and CSR do not matchN)r�r�
valid_privkeyrr�r��OpenSSL�crypto�load_certificate_request�
FILETYPE_ASN1r��dump_certificate_request�FILETYPE_PEMrr�r��	valid_csr�csr_matches_pubkey)rnr��csr_obj�cert_buffers    r;�validate_key_csrr|s��,�{�{�;�4�4�W�[�[�A��l�l�@�A�A�
��8�8�u���n�n�=�=����,�,�c�h�h�8�G�!�.�.�A�A����+�+�W��K��(�(�3�8�8�[�%�8�C��8�8�K�1�1�#�(�(�;��,�,�D�E�E��8�8�����1�1��H�H�g�k�k�+��l�l�#A�B�B�+�$�8�r=�default_installer�checkpoints�pluginsc�~�tj|||d��}|�"|j|�|j�yy)a�Revert configuration the specified number of checkpoints.

    :param str default_installer: Default installer name to use for the rollback
    :param int checkpoints: Number of checkpoints to revert.
    :param config: Configuration.
    :type config: :class:`certbot.configuration.NamespaceConfiguration`
    :param plugins: Plugins available
    :type plugins: :class:`certbot._internal.plugins.disco.PluginsRegistry`

    z,Which installer should be used for rollback?)�questionN)�plugin_selection�pick_installerrhrH)r}r~r$rrLs     r;�rollbackr�:sH��!�/�/��!�7�6'�(�I����&�&�{�3�����r=�cli_arg_path�pem_pathc��|j|�r7tj|dd��tjj|�fStj|dd�}|dtjj|d�fS)a'Open a pem file.

    If cli_arg_path was set by the client, open that.
    Otherwise, uniquify the file path.

    :param str cli_arg_path: the cli arg name, e.g. cert_path
    :param str pem_path: the pem file path to open

    :returns: a tuple of file object and its absolute file path

    i��wb)�chmod�moder�)�set_by_userr�	safe_openr!r*rC�unique_file)r$r�r��uniqs    r;r4r4Ssp�����,�'��~�~�h�e�$�?��G�G�O�O�H�%�&�	&����H�e�T�2�D���7�B�G�G�O�O�D��G�,�,�,r=r-r:c�r�	|j|�|j�y#|j�wxYw)z�Saves chain_pem at a unique path based on chain_path.

    :param bytes chain_pem: certificate chain in PEM format
    :param str chain_file: chain file object

    N)r5r6)r-r:s  r;r7r7gs.�������#������
����s�$�6r)Sr}r��loggingrG�typingrrrrrrr	r
�cryptography.hazmat.backendsr�-cryptography.hazmat.primitives.asymmetric.rsar�josepyr�r
rrrrrr�rr1rr�rrrrArrr�certbot._internalrrrrrrr�certbot._internal.pluginsr�plugin_discor r��certbot.compatr!�certbot.displayr"r�r!�certbot.interfacesr#�	getLoggerrzr�r��JWK�RegistrationResourcer5r<r~r4rNrar�r�r�r�r�r�r�r|�int�PluginsRegistryr�r4rlr7rwr=r;�<module>r�s���������������8�N�������&�0�&���!�����%�*�!�'�!�+�%�;�C��.�0�-�	��	�	�8�	$��JN�0��!>�!>�0�T�X�X�0�'��(E�(E�F�0�)�2�2�0�4��!>�!>��3��@�]�2�2��s��(
�
�T�3�T�8<�D�]�2�2�D�^�D��h��u�d�{�3�4�D������)=�)=�=�>�D�N/�{�3�3�/�]�=Z�=Z�/�!)�(�C�5�$�;�*?�!@�/�EM�Eb�Eb�/�d|-�|-�~+C�d�h�h�+C�X�d�h�h�-?�+C�4�+C�\���#��"�2�2��=I�=Y�=Y��^b��2-�=�8�8�-�!$�-�03�-�8=�b�#�g��-�(
�5�
�b�
�T�
r=

Zerion Mini Shell 1.0