HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /proc/1784574/root/lib/python3/dist-packages/certbot/_internal/__pycache__/
Upload File :
Current File : //proc/1784574/root/lib/python3/dist-packages/certbot/_internal/__pycache__/main.cpython-311.pyc
�

E��c����dZddlmZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZddlmZdd	lm
Z
dd
lmZddlmZddlmZddlZddlZdd
lmZddlmZddlmZddlZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl m"Z"ddl m#Z#dd
l 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,mZ/dd l0m1Z2dd!l0m3Z4dd"l5m6Z6dd#l5m7Z7dd$l5m8Z8dd%l9m:Z;ddl9mZ<dd&l=m>Z>d'Z?ej@eA��ZBd(ejCd)dfd*�ZD		dod+ejEd(ejCd,e
eeFd-e
eFd.e
e*jGd)e
e*jGfd/�ZHd(ejCd0e*jGd)eIfd1�ZJd(ejCd,eeFd0e*jGd)eeFe
e*jGffd2�ZKd(ejCd.e*jGd)eeFe
e*jGffd3�ZLd(ejCd,eeFd)ee
eFe
e*jGffd4�ZMd(ejCd,eeFd-eFd)eeIe
e*jGffd5�ZNd(ejCd,eeFd-eFd)ee
eFe
e*jGffd6�ZOed7��ZPd8eePd9eePd)eeePeePffd:�ZQd;eFd<eeFd)eFfd=�ZRd(ejCd>eeFd-eFd?eeFd)df
d@�ZS	dpd(ejCdAe
ejTdBe
eFd)eeeFeFffdC�ZU	dqd(ejCdEe
ejVd.e
e*jGdFeId)df
dG�ZW	dpd(ejCdHe
eFdIe
eFdJe
eFd)df
dK�ZXd(ejCd)eIfdL�ZYd(ejCdHe
eFdMe
eFdIe
eFd)df
dN�ZZd(ejCd)ee!j[e
ej\ffdO�Z]d(ejCd)dfdP�Z^d(ejCdQe
ej_dAe
ejTd)ejEfdR�Z`d(ejCdSe2jad)e
eFfdT�Zbd(ejCdSe2jad)e
eFfdU�Zcd(ejCdSe2jad)e
eFfdV�Zdd(ejCdSe2jad)e
eFfdW�Zed(ejCd.e
e*jGd)e
eFfdX�Zf	dpd(ejCd+ejEd,eeFd.e
e*jGd)df
dY�Zgd(ejCdZe2jad)e
eFfd[�Zhd(ejCd)ejCfd\�Zid(ejCd)dfd]�Zjd(ejCdZe2jad)dfd^�Zkd(ejCdZe2jad)e
eFfd_�Zld(ejCdZe2jad)dfd`�Zmd(ejCdSe2jad)dfda�Znd(ejCdSe2jad)dfdb�Zod(ejCdSe2jad)dfdc�Zpd(ejCdSe2jad)dfdd�Zqd(ejCdSe2jad)e
eFfde�Zrd(ejCdZe2jad)e
eFfdf�Zsd(ejCd+ejEd)ee
eFe
eFe
eFffdg�Ztd(ejCdZe2jad.e*jGd)dfdh�Zud(ejCdZe2jad)dfdi�Zvd(ejCdSe2jad)dfdj�Zwd(ejCd)dfdk�Zxed(ejCd)e	ee.jye.jzfddffdl���Z{dpdme
eeFd)e
eeFe|ffdn�Z}dS)rzCertbot main entry point.�)�contextmanagerN)�cast)�	Generator)�IO)�Iterable)�List)�Optional)�Tuple)�TypeVar)�Union)�client)�errors)�messages)�
configuration)�crypto_util)�
interfaces)�util)�account)�cert_manager)�cli)�	constants)�eff)�hooks)�log)�renewal)�snap_config)�storage)�updater)�obj)�disco)�	selection)�
filesystem)�misc)�os)�ops)�enhancementsz?User chose to cancel the operation and may reinvoke the client.�config�returnc��|jdksJ�|js|jrdStjt
jdd���dS)z�Potentially suggest a donation to support Certbot.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :returns: `None`
    :rtype: None

    �renewNz�If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-leF��pause)�verb�staging�quietr�atexit_register�display_util�notification�r's �8/usr/lib/python3/dist-packages/certbot/_internal/main.py� _suggest_donation_if_appropriater5<sd���;�'�!�!�!�!�
�~����������!�	K���������	le_client�domains�certname�lineagec	���tj|��	|�ptjd�|jrdndt
j|p|����������tj
||||��n�|�tjd���tjd�|jrdndt
j|�������|�
||��}|d	urtjd
���|�-tj||���|j��tj|��n#tj|��wxYw|S)a,Authenticate and enroll certificate.

    This method finds the relevant lineage, figures out what to do with it,
    then performs that action. Includes calls to hooks, various reports,
    checks, and requests for user input.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param domains: List of domain names to get a certificate. Defaults to `None`
    :type domains: `list` of `str`

    :param certname: Name of new certificate. Defaults to `None`
    :type certname: str

    :param lineage: Certificate lineage object. Defaults to `None`
    :type lineage: storage.RenewableCert

    :returns: the issued certificate or `None` if doing a dry run
    :rtype: storage.RenewableCert or None

    :raises errors.Error: if certificate could not be obtained

    N�{action} for {domains}z-Simulating renewal of an existing certificatez Renewing an existing certificate��actionr8z5Domain list cannot be none if the lineage is not set.� Simulating a certificate request�Requesting a certificateFz!Certificate could not be obtained)r�pre_hookr1�notify�format�dry_run�internal_display_util�summarize_domain_list�namesr�
renew_certr�Error�obtain_and_enroll_certificate�deploy_hook�live_dir�	post_hook)r7r'r8r9r:s     r4�_get_and_save_certrNVs���8
�N�6���� ���
��(�/�/��~�N�J�J�+M�1�G��Hb�SZ�S`�S`�Sb�Sb�c�c�0���
�
�
�
��v�w�	�7�C�C�C�C����l�#Z�[�[�[���(�/�/�AG��6�=�=�5�1�G��P�P�0���
�
�
� �=�=�g�x�P�P�G��%����l�#F�G�G�G��"��!�&�'�-�-�/�/�7�;K�L�L�L�
�������������������Ns�D)E�E*�certc	���|j���}|j���}||krdStjd��otjd��}|s(tjd|�d|j�d|�d�dd	dd�
��rdStjd��r#tj	d|j�d
|�d|�d����|�
��|_dS)a�
    This function ensures that the user will not implicitly migrate an existing key
    from one type to another in the situation where a certificate for that lineage
    already exist and they have not provided explicitly --key-type and --cert-name.
    :param config: Current configuration provided by the client
    :param cert: Matching certificate that could be renewed
    :returns: Whether a key type migration is going ahead.
    :rtype: `bool`
    F�key_typer9zAn z certificate named z7 already exists. Do you want to update its key type to �?zUpdate key typezKeep existing key type)�	yes_label�no_label�default�force_interactiveTz?Are you trying to change the key type of the certificate named z from z to zr? Please provide both --cert-name and --key-type on the command line to confirm the change you are trying to make.)rQ�upper�private_key_typer�
set_by_clir1�yesno�lineagenamerrI�lower)r'rO�new_key_type�cur_key_type�is_confirmed_via_clis     r4�%_handle_unexpected_key_type_migrationr`�s9���?�(�(�*�*�L��(�.�.�0�0�L��|�#�#��u��>�*�5�5�T�#�.��:T�:T����|�1�	2�l�	2�	2�t�/?�	2�	2�".�	2�	2�	2�#�.F���	 � � ���t��~�j�!�!�
��l�
&���
&�
&�'3�
&�
&�9E�
&�
&�
&�
�
�	
�#�(�(�*�*�F�O��5r6c�@�t||��d�|�����}d�|jj|d�|��tj���}|js |j	stj|dddd���rd	|fStjd
�|tjd�tjdd
���tj�����t#jt&���)aFigure out what to do if a previous cert had a subset of the names now requested

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param domains: List of domain names
    :type domains: `list` of `str`

    :param cert: Certificate object
    :type cert: storage.RenewableCert

    :returns: Tuple of (str action, cert_or_None) as per _find_lineage_for_domains_and_certname
              action can be: "newcert" | "renew" | "reinstall"
    :rtype: `tuple` of `str`

    �, a You have an existing certificate that contains a portion of the domains you requested (ref: {0}){br}{br}It contains these names: {1}{br}{br}You requested these names for the new certificate: {2}.{br}{br}Do you want to expand and replace this existing certificate with the new certificate?��br�Expand�Cancelz--expandT��cli_flagrVr*z�To obtain a new certificate that contains these names without replacing your existing certificate for {0}, you must use the --duplicate option.{br}{br}For example:{br}{br}{1} --duplicate {2}� �N)r`�joinrGrC�
configfile�filenamer$�linesep�expand�renew_by_defaultr1rZrBr�cli_command�sys�argvrrI�USER_CANCELLED)r'r8rO�existing�questions     r4�_handle_subset_cert_requestrw�s��(*�&�$�7�7�7��y�y������&�&�H�	0�

�f�T�_�
%�
�
�Y�Y�w�
�
��
�
���

��}���/��<�3E��(�H�z�T�4S�4S�4S����}����	2�39�&���O�S�X�X�c�h�q�r�r�l�3�3��z�39�3
�3
�	����,�~�
&�
&�&r6c��t||��}|���sd|fS|stj||��rd|fS|jrd|fSd�|jjtj	���}|j
dkrd}n
|j
dkrd}|d	g}tj||d
d���}|d
tj
krtjd
���|dd
krd|fS|ddkrd|fSt!d���)a�Figure out what to do if a lineage has the same names as a previously obtained one

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param lineage: Certificate lineage object
    :type lineage: storage.RenewableCert

    :returns: Tuple of (str action, cert_or_None) as per _find_lineage_for_domains_and_certname
              action can be: "newcert" | "renew" | "reinstall"
    :rtype: `tuple` of `str`

    �	reinstallr*z�You have an existing certificate that has exactly the same domains or certificate name you requested and isn't close to expiry.{br}(ref: {0}){br}{br}What would you like to do?rc�runz.Attempt to reinstall this existing certificate�certonlyz%Keep the existing certificate for nowzBRenew & replace the certificate (may be subject to CA rate limits)rT)rUrVz.Operation canceled. You may re-run the client.rjzThis is impossible)r`�ensure_deployedr�should_renewryrCrlrmr$rnr-r1�menu�CANCELrrI�AssertionError)r'r:�is_key_type_changingrv�keep_opt�choices�responses       r4�_handle_identical_cert_requestr��sa�� A���Q�Q���"�"�$�$�$��G�#�#�� �w�3�F�G�D�D� �����
��$��G�#�#�	;�
�f�W�
�
(�R�Z�f�8�8�	
��{�e���C���	��
�	"�	"�:���S�U�G�� ��7�,-��G�G�G�H���{�l�)�)�)��l�<�>�>�	>���{�a����G�#�#�	�!���	�	�����
�-�
.�
.�.r6c��|jrdStj||��\}}|�|�dS|�t||��S|�t	|||��SdS)aDetermine whether there are duplicated names and how to handle
    them (renew, reinstall, newcert, or raising an error to stop
    the client run if the user chooses to cancel the operation when
    prompted).

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param domains: List of domain names
    :type domains: `list` of `str`

    :returns: Two-element tuple containing desired new-certificate behavior as
              a string token ("reinstall", "renew", or "newcert"), plus either
              a RenewableCert instance or `None` if renewal shouldn't occur.
    :rtype: `tuple` of `str` and :class:`storage.RenewableCert` or `None`

    :raises errors.Error: If the user would like to rerun the client again.

    ��newcertNN�NN)�	duplicater�find_duplicative_certsr�rw)r'r8�ident_names_cert�subset_names_certs    r4�_find_lineage_for_domainsr�)sv��2�����*6�*M�f�V]�*^�*^�'��'���$5�$=����#�-�f�6F�G�G�G�	�	&�*�6�7�<M�N�N�N��:r6c�z�t|||��\}}|dkrt�d��|dk|fS)abFinds an existing certificate object given domains and/or a certificate name.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param domains: List of domain names
    :type domains: `list` of `str`

    :param certname: Name of certificate
    :type certname: str

    :returns: Two-element tuple of a boolean that indicates if this function should be
              followed by a call to fetch a certificate from the server, and either a
              RenewableCert instance or None.
    :rtype: `tuple` of `bool` and :class:`storage.RenewableCert` or `None`

    ryz Keeping the existing certificate)�&_find_lineage_for_domains_and_certname�logger�info)r'r8r9r>r:s     r4�
_find_certr�RsG��&=�V�W�h�W�W�O�F�G�
�������6�7�7�7��k�!�G�+�+r6c��|st||��Stj||��}|r�|rotj||��}|rXt	|��t	|��kr8t||��t
||||�����d|fSt||��S|rdStj
d�|�����)a�Find appropriate lineage based on given domains and/or certname.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param domains: List of domain names
    :type domains: `list` of `str`

    :param certname: Name of certificate
    :type certname: str

    :returns: Two-element tuple containing desired new-certificate behavior as
              a string token ("reinstall", "renew", or "newcert"), plus either
              a RenewableCert instance or None if renewal should not occur.

    :rtype: `tuple` of `str` and :class:`storage.RenewableCert` or `None`

    :raises errors.Error: If the user would like to rerun the client again.

    r*r�z}No certificate with name {0} found. Use -d to specify domains, or run certbot certificates to see possible certificate names.)r�r�lineage_for_certname�domains_for_certname�setr`�_ask_user_to_confirm_new_namesrGr�r�ConfigurationErrorrC)r'r8r9r:�computed_domainss     r4r�r�ks���.�:�(���9�9�9��/���A�A�G����	(�+�@���R�R���
(�C�(8�$9�$9�S��\�\�$I�$I�5�f�g�F�F�F�.�v�w��/6�}�}���@�@�@���'�'�-�f�g�>�>�>�	����
�
#�%B�BH�&��BR�BR�T�T�Tr6�T�after�beforec�
�tt|��t|��z
��}tt|��t|��z
��}|���|���||fS)zWGet lists of items removed from `before`
    and a lists of items added to `after`
    )�listr��sort)r�r��added�removeds    r4�_get_added_removedr��sd��
��U���c�&�k�k�)�*�*�E��3�v�;�;��U���+�,�,�G�	�J�J�L�L�L��L�L�N�N�N��'�>�r6�	character�stringsc�~�|sd}ndd�|��z}|�|tj���S)z%Format list with given character
    z
{br}(None)z	{br}{ch} )�chrd)rkrCr$rn)r�r��	formatteds   r4�_format_listr��sP���<� �	�	��+�"2�"2�7�";�";�;�	�����
�:����r6�new_domains�old_domainsc��|jrdSt||��\}}d�|td|��td|��tj���}t
j|ddd�	��stj	d
���dS)aAsk user to confirm update cert certname to contain new_domains.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param new_domains: List of new domain names
    :type new_domains: `list` of `str`

    :param certname: Name of certificate
    :type certname: str

    :param old_domains: List of old domain names
    :type old_domains: `list` of `str`

    :returns: None
    :rtype: None

    :raises errors.ConfigurationError: if cert name and domains mismatch

    Nz�You are updating certificate {0} to include new domain(s): {1}{br}{br}You are also removing previously included domain(s): {2}{br}{br}Did you intend to make this change?�+�-rczUpdate certificaterfT)rUz2Specified mismatched certificate name and domains.)
�renew_with_new_domainsr�rCr�r$rnr1rZrr�)r'r�r9r�r�r��msgs       r4r�r��s���.�$����'��[�A�A�N�E�7�1�17����C��'�'��C��)�)��*�	28�2�2����c�#7��4�P�P�P�^��'�(\�]�]�]�^�^r6�	installerrvc���d}|j}|jr|j}n|rtj||��}|st	j||��}|s|st
jd���||fS)aRetrieve domains and certname from config or user input.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param installer: Installer object
    :type installer: interfaces.Installer

    :param `str` question: Overriding default question to ask the user if asked
        to choose from domain names.

    :returns: Two-part tuple of domains and certname
    :rtype: `tuple` of list of `str` and `str`

    :raises errors.Error: Usage message, if parameters are not used correctly

    Nz�Please specify --domains, or --installer that will help in domain names autodiscovery, or --cert-name for an existing certificate name.)r9r8rr��display_ops�choose_namesrrI)r'r�rvr8r9s     r4�_find_domains_or_certnamer��s���(�G���H�
�~�F��.���
�F��3�F�H�E�E���@��*�9�h�?�?���L�8�L��l�K�L�L�	L��H��r6T�
installer_err�new_or_renewed_certc����g}|rm�jdkr'|�d�j�d�j�d���n;|�d�j�dtj�dt�|������|rl�jr|�d��nOt���r$|�d	tj�d
���n�js|�d��|sdS�fd
�tj
dtjfD��\}}}t||���tjd��t|d���|D]}tjd|�����|rt��dSdS)a�Displays post-run/certonly advice to the user about renewal and installation.

    The output varies by runtime configuration and any errors encountered during installation.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param installer_err: The installer/enhancement error encountered, if any.
    :type error: Optional[errors.Error]

    :param lineage: The resulting certificate lineage from the issuance, if any.
    :type lineage: Optional[storage.RenewableCert]

    :param bool new_or_renewed_cert: Whether the verb execution resulted in a certificate
                                     being saved (created or renewed).

    r{zMThe certificate was saved, but was not successfully loaded by the installer (z\) due to the installer failing to reload. After fixing the error shown below, try reloading z
 manually.zBThe certificate was saved, but could not be installed (installer: zM). After fixing the error shown below, try installing it again by running:
  z install --cert-name z�Certificates created using --csr will not be renewed automatically by Certbot. You will need to renew the certificate before it expires, by running the same Certbot command again.z�This certificate will not be renewed automatically. Autorenewal of --manual certificates requires the use of an authentication hook script (--manual-auth-hook) but one was not provided. To renew this certificate, repeat this same z. command before the certificate's expiry date.z�The certificate will need to be renewed before it expires. Certbot can automatically renew the certificate in the background, but you may need to take steps to enable that functionality. See https://certbot.org/renewal-setup for instructions.Nc�b��g|]+}tj���r	�js|nd��,S)�)rr�stdout�isattyr/)�.0�cr's  �r4�
<listcomp>z&_report_next_steps.<locals>.<listcomp>DsN���Y�Y�Y�#$�%(�J�$5�$5�$7�$7�T���T�q�q�RT�Y�Y�Yr6�
)�endzNEXT STEPS:r�z- )r-�appendr�rrq�!_cert_name_from_config_or_lineage�csr�_is_interactive_only_auth�preconfigured_renewalr�
ANSI_SGR_BOLD�ANSI_SGR_RESET�printr1rB)	r'r�r:r��steps�bold_on�nl�bold_off�steps	`        r4�_report_next_stepsr�sM���(�E����;�*�$�$��L�L�b��$�b�b�EK�EU�b�b�b�
�
�
�
�
�L�L�H��#�H�H�"%�/�H�H�5�V�W�E�E�H�H�
�
�
��K��:�	K��L�L�)�
*�
*�
*�
*�'�v�
.�
.�	K��L�L�]�!�_�]�]�]�
�
�
�
��-�	K��L�L�J�
K�
K�
K�����Y�Y�Y�Y�)-�);�T�4�CV�(W�Y�Y�Y��W�b�(�	�'�r�������
�&�&�&�	�(�������)�)����K��K�K�(�(�(�(���
�������r6�	cert_path�fullchain_path�key_pathc
�x�|jrtjd��dS|r|s
Jd���d}|jrt	|��sd}tjd�|t
j|�����|rd�|��nd||j	dkrd	nd�
����dS)a�Reports the creation of a new certificate to the user.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param cert_path: path to certificate
    :type cert_path: str

    :param fullchain_path: path to full chain
    :type fullchain_path: str

    :param key_path: path to private key, if available
    :type key_path: str

    :returns: `None`
    :rtype: None

    �The dry run was successful.N� No certificates saved to report.r�z_
Certbot has set up a scheduled task to automatically renew this certificate in the background.z�
Successfully received certificate.
Certificate is saved at: {cert_path}
{key_msg}This certificate expires on {expiry}.
These files will be updated when the certificate renews.{renewal_msg}{nl}zKey is saved at:         {}
rzr�)r��expiry�key_msg�renewal_msgr�)
rDr1rBr�r�rCr�notAfter�dater-)r'r�r�r�r�s     r4�_report_new_certr�Rs���(�~����9�:�:�:����K��K�K�)K�K�K�K��K�
�#�9�,E�f�,M�,M�9�8����
T�V\�U[�$��'�	�2�2�7�7�9�9�HP�X�3�:�:�8�D�D�D�VX�#��{�e�+�+�t�t��V\�V
�V
�	����r6c�.�|jdkr	|j�dSdS)zP Whether the current authenticator params only support interactive renewal.
    �manualNTF)�
authenticator�manual_auth_hookr3s r4r�r�s$����x�'�'�F�,C�,K��t��5r6�
chain_pathc��|jrtjd��dS|r|s
Jd���tj|�����}tjd�||||�����dS)a� --csr variant of _report_new_cert.

    Until --csr is overhauled (#8332) this is transitional function to report the creation
    of a new certificate using --csr.
    TODO: remove this function and just call _report_new_cert when --csr is overhauled.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param str cert_path: path to cert.pem

    :param str chain_path: path to chain.pem

    :param str fullchain_path: path to fullchain.pem

    r�Nr�z�
Successfully received certificate.
Certificate is saved at:            {cert_path}
Intermediate CA chain is saved at:  {chain_path}
Full certificate chain is saved at: {fullchain_path}
This certificate expires on {expiry}.)r�r�r�r�)rDr1rBrr�r�rC)r'r�r�r�r�s     r4�_csr_report_new_certr��s���$�~����9�:�:�:����K��K�K�)K�K�K�K�
�
!�)�
,�
,�
1�
1�
3�
3�F���
0�28���J�)�&�28�2
�2
�	�	�	�	�	r6c���dtddf�fd�}tj���}d}�j�|��j��}�n�|���}t|��dkr.t
j|��}|stj	d���|}�n-t|��dkr
|d}�n�j
��jst
j���_
	tj�||���\}}tjd	��n�#tj$r�tj	t$j	f$r�}t&�d
d���t%j|��r2t-jt1t$j	|����}d
|��}nt|��}tj	d|�����d}~wwxYw|j�_||fS)a�Determine which account to use.

    If ``config.account`` is ``None``, it will be updated based on the
    user input. Same for ``config.email``.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :returns: Account and optionally ACME client API (biproduct of new
        registration).
    :rtype: tuple of :class:`certbot._internal.account.Account` and :class:`acme.client.Client`

    :raises errors.Error: If unable to register an account with ACME server

    �terms_of_servicer(Nc����jrdSd�|��}tj|dd���}|st	jd���dS)NzpPlease read the Terms of Service at {0}. You must agree in order to register with the ACME server. Do you agree?z--agree-tosTrgz?Registration cannot proceed without accepting Terms of Service.)�tosrCr1rZrrI)r�r��resultr's   �r4�_tos_cbz#_determine_account.<locals>._tos_cb�so����:�	��F�'�'-�v�.>�'?�'?�	��#�C�-�SW�X�X�X���	%��,�$�%�%�
%�	%�	%r6rjzNo account has been chosen.r)�tos_cbzAccount registered.r�T)�exc_infoz#Error returned by the ACME server: z0Unable to register an account with ACME server. )�strr�AccountFileStorage�load�find_all�lenr��choose_accountrrI�email�register_unsafely_without_email�	get_emailr
�registerr1rB�MissingCommandlineFlag�
acme_messagesr��debug�
is_acme_errorrE�describe_acme_errorr�id)	r'r��account_storage�acme�acc�accounts�
potential_acc�err�err_msgs	`        r4�_determine_accountr�s���$
%�#�
%�$�
%�
%�
%�
%�
%�
%��0��8�8�O�+/�D�
�~�!��"�"�6�>�2�2���"�+�+�-�-���x�=�=�1���'�6�x�@�@�M� �
B��l�#@�A�A�A��C�C�
��]�]�a�
�
��1�+�C�C��|�#�F�,R�#�*�4�6�6���
R�"�O��O�G�=�=�=�	��T��#�$9�:�:�:�:���0�
�
�
���L�-�"5�6�	
R�	
R�	
R����R�$��/�/�/� �.�s�3�3�'�3�G��]�0�#�6�6�8�8�G�M�G�M�M�G�G�!�#�h�h�G��l�P�w�P�P�R�R�R�����	
R�����V�F�N���9�s�#.D�*G	�<BG�G	c���|j}|�d}tj|dddd���}|sdS|jsJ�|jstj|��|_tjtj
tj||j��dd���||j���	tj|�fd	�gd
�d���nv#tj$rt�d���YdSt"$r=}d
}|�|j|j�|��}tj|���d}~wwxYwtj|��dS)a�Does the user want to delete their now-revoked certs? If run in non-interactive mode,
    deleting happens automatically.

    :param config: parsed command line arguments
    :type config: configuration.NamespaceConfig

    :returns: `None`
    :rtype: None

    :raises errors.Error: If anything goes wrong, including bad user input, if an overlapping
        archive dir is found for the specified lineage, etc ...
    Nz{Would you like to delete the certificate(s) you just revoked, along with all earlier and later versions of the certificate?zYes (recommended)�NoT)rSrTrVrUzutf-8)�encoding�default_encodingc����S�N�)�x�archive_dirs �r4�<lambda>z(_delete_if_appropriate.<locals>.<lambda>s����r6c��|jSr)r�r
s r4rz(_delete_if_appropriate.<locals>.<lambda>s���
�r6c��|jSr)r[rs r4rz(_delete_if_appropriate.<locals>.<lambda>s
��QR�Q^�r6zhNot deleting revoked certificates due to overlapping archive dirs. More than one certificate is using %sz_config.default_archive_dir: {0}, config.live_dir: {1}, archive_dir: {2},original exception: {3})�delete_after_revoker1rZr�r9r�cert_path_to_lineager�full_archive_path�	configobj�	ConfigObj�renewal_file_for_certname�match_and_check_overlapsr�OverlappingMatchFoundr��warning�	ExceptionrC�default_archive_dirrLrI�delete)r'�attempt_deletionr��ers    @r4�_delete_if_appropriater�s�����1����O��'�-�c�=P�[_�@D�d�T�T�T������������?�D�&�;�F�C�C����+����1�&�&�/�J�J� �7�
<�
<�
<�
�F�O�	%�%�K�
 ��-�f�7L�7L�7L�7L�6M�.E�.E�G^�G^�	`�	`�	`�	`���'�������?�@K�	M�	M�	M����� � � �)���j�j��3�V�_�k�ST�U�U���l�3��������	 �����������s�B:�:*D-�'	D-�08D(�(D-r�c��|�.t|��\}}t�d|��nd\}}tj|||||���S)a�Initialize Let's Encrypt Client

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param authenticator: Acme authentication handler
    :type authenticator: Optional[interfaces.Authenticator]
    :param installer: Installer object
    :type installer: interfaces.Installer

    :returns: client: Client object
    :rtype: client.Client

    NzPicked account: %rr��r�)rr�r�r
�Client)r'r�r�r�r�s     r4�_init_le_clientr"'sW��$� �&�v�.�.�	��T����)�3�/�/�/�/��	��T��=���m�Y�T�J�J�J�Jr6�unused_pluginsc��tj|��}|���}|sd|j�d�Sd}t	j|ddd���}|sdSt
|��\}}tj||d	d	|�
��}|j	stjd���|j	�|j
��tj|��}	|	�|j��t	jd��d	S)
a:Deactivate account on server

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: plugins_disco.PluginsRegistry

    :returns: `None` or a string indicating an error
    :rtype: None or str

    z+Could not find existing account for server �.zCAre you sure you would like to irrevocably deactivate your account?�
Deactivate�AbortT)rSrTrUzDeactivation aborted.Nr �ACME client is not set.zAccount deactivated.)rr�r��serverr1rZrr
r!r�rrI�deactivate_registration�regrrrB)
r'r#r�r��prompt�wants_deactivater�r��	cb_client�
account_filess
          r4�
unregisterr0Cs���0��8�8�O��'�'�)�)�H��N�M�V�]�M�M�M�M��F�#�)�&�L�SZ�26�8�8�8���'�&�&�"�6�*�*�I�C���
�f�c�4��D�A�A�A�I��>�6��l�4�5�5�5��N�*�*�3�8�4�4�4��.�v�6�6�M������(�(�(���.�/�/�/��4r6c�|�tj|��}|���}|rdSt|��dS)a<Create accounts on the server.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: plugins_disco.PluginsRegistry

    :returns: `None` or a string indicating an error
    :rtype: None or str

    zmThere is an existing account; registration of a duplicate account with this command is currently unsupported.N)rr�r�r)r'r#r�r�s    r4r�r�nsL�� �0��8�8�O��'�'�)�)�H�� ����v�����4r6c��tj|��}|���}|sd|j�d�S|j�!|jst
jd���|_t|��\}}tj
||dd|���}|jstj
d���d}|jr$d	�|j�d
��D��}|jj}|j�|j�|jj�|��������|_|j�|�
��|_|�||j��|jst+jd��nAt/j||��t+jd�|j����dS)a<Modify accounts on the server.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: plugins_disco.PluginsRegistry

    :returns: `None` or a string indicating an error
    :rtype: None or str

    �.Could not find an existing account for server r%NF)�optionalr r(r	c��g|]}d|z��S)�mailto:r	)r�r�s  r4r�z"update_account.<locals>.<listcomp>�s��O�O�O�e�	�E�)�O�O�Or6�,)�contact)�body)�urizFAny contact information associated with this account has been removed.z'Your e-mail address was updated to {0}.)rr�r�r)r�r�r�r�rr
r!r�rrI�splitr+r:�update_registration�updater9�update_regrr1rBr�prepare_subscriptionrC)	r'r#r�r�r�r�r.�acc_contacts�
prev_regr_uris	         r4�update_accountrB�s��� �0��8�8�O��'�'�)�)�H��Q�P��
�P�P�P�P�
�|��F�$J��"�,�e�<�<�<���"�6�*�*�I�C���
�f�c�4��D�A�A�A�I��>�6��l�4�5�5�5�#%�L�
�|�P�O�O�v�|�7I�7I�#�7N�7N�O�O�O���H�L�M��~�1�1�#�(�/�/�
�X�]�
!�
!�,�
!�
7�
7�3B�39�39�:�:�C�H�
�x���=��1�1�C�H�����Y�^�4�4�4��<�\���B�	C�	C�	C�	C�	� ���-�-�-���E�L�L�V�\�Z�Z�[�[�[��4r6c��tj|��}|���}|sd|j�d�St	|��\}}tj||dd|���}|jstj	d���|j�
|j��}d|j�d�d|j��g}g}	|j
jD]4}
|
�d	��r|	�|
d
d����5|�d�t%|	��dkrd
ndt%|	��dkrd�|	��nd����t)jd�|����dS)a^Fetch account info from the ACME server and show it to the user.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: plugins_disco.PluginsRegistry

    :returns: `None` or a string indicating an error
    :rtype: None or str

    r3r%Nr r(zAccount details for server �:z  Account URL: r6�z  Email contact{}: {}rj�sr�rrb�noner�)rr�r�r)rr
r!r�rrI�query_registrationr+r:r9r8�
startswithr�rCr�rkr1rB)r'r#r�r�r�r�r.r+�output�emailsr8s           r4�show_accountrL�s��� �0��8�8�O��'�'�)�)�H��Q�P��
�P�P�P�P�"�6�*�*�I�C���
�f�c�4��D�A�A�A�I��>�6��l�4�5�5�5��>�,�,�S�X�6�6�D�<�F�M�<�<�<�*���*�*�,�F��F��9�$�'�'�����i�(�(�	'��M�M�'�!�"�"�+�&�&�&��
�M�M�)�0�0�#&�v�;�;��?�?�C�C��14�V���q���D�I�I�f�-�-�-�f�N�N�O�O�O����	�	�&�)�)�*�*�*��4r6c��|r|jS|jr|jS	tj|��}|S#tj$rYnwxYwdSr)r[r9rrrrI)r'r:�	cert_names   r4r�r��si�����"�"�	������
� �5�f�=�=�	�����<�
�
�
���
�����4s�/�A�Ac��|r|n|}|j�J�|�||j|j|j|j��|�||j��dS)a�Install a cert

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param le_client: Client object
    :type le_client: client.Client

    :param domains: List of domains
    :type domains: `list` of `str`

    :param lineage: Certificate lineage object. Defaults to `None`
    :type lineage: storage.RenewableCert

    :returns: `None`
    :rtype: None

    N)r��deploy_certificater�r�r��enhance_config)r'r7r8r:�
path_providers     r4�
_install_certrSsx��*FM�:X�'�'�RX���"�.�.�.�
� � ��-�*@�-�BY�!.�!9�=�;W�Y�Y�Y�
���W�m�&>�?�?�?�?�?r6�pluginsc�4�	tj||d��\}}n+#tj$r}t	|��cYd}~Sd}~wwxYw|jo|j}|js'|s%d}tj	|dd|���d|_tj||��stjd���|jrt|��}n(tj|��rtjd���|jrM|jrFt!|��t#||��\}}t%|d|�	��}t'|||��ntjd
���tj|��r1tj||j��}	tj|	|||��dS)a'Install a previously obtained cert in a server.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param plugins: List of plugins
    :type plugins: plugins_disco.PluginsRegistry

    :returns: `None` or the error message
    :rtype: None or str

    �installNz,Which certificate would you like to install?F��allow_multiple�
custom_promptr�VOne ore more of the requested enhancements are not supported by the selected installerzLOne or more of the requested enhancements require --cert-name to be provided�r�r�z�Path to certificate or key was not defined. If your certificate is managed by Certbot, please use --cert-name to define which certificate you would like to install.)�plug_sel�choose_configurator_pluginsr�PluginSelectionErrorr�r�r�r9r�
get_certnamesr&�
are_supported�NotSupportedError�_populate_from_certname�
are_requestedr��_check_certificate_and_keyr�r"rSr��enable)
r'rTr��_r�custom_cert�certname_questionr8r7r:s
          r4rVrVs���$��;�F�G�Y�W�W��	�1�1���&�����1�v�v�
�
�
�
�
�
����������?�7�v�'7�K��?�0�;�0�J��&�4��I�e�+�-�-�-�-.�0����%�f�i�8�8�V��&�(U�V�V�	V�
��N�(��0�0���	�	#�F�	+�	+�N��'�)M�N�N�	N���F�6�+�F�"�6�*�*�*�.�v�y�A�A�
���#�F�$�)�T�T�T�	��f�i��1�1�1�1��'�)E�F�F�	F��!�&�)�)�A��3�F�F�O�L�L����G�W�i��@�@�@��4s��A�?�A�Ac��tj||j��}|s|S|js|j|j_|js|j|j_|js|j|j_|js|j|j_|S)zfHelper function for install to populate missing config values from lineage
    defined by --cert-name.)rr�r9r��	namespacer�r�r�)r'r:s  r4rbrb[s����/����H�H�G����
��?�5�$+�$4���!���7�%,�%6���"���9�&-�&8���#�� �A�*1�*@���'��Mr6c��tj�tj|j����s,t
jd�|j�����tj�tj|j	����s,t
jd�|j	�����dS)Nz-Error while reading certificate from path {0}z-Error while reading private key from path {0})
r$�path�isfiler"�realpathr�rr�rCr�r3s r4rdrdms���
�7�>�>�*�-�f�.>�?�?�@�@�H��'�).�.4�f�V�5E�.F�.F�H�H�	H�
�7�>�>�*�-�f�o�>�>�?�?�G��'�).�.4�f�V�_�.E�.E�G�G�	G�G�Gr6c���t�d|j��|j�gn|j}|����|��}t�d|��t	jtjd���}|js!|j	s|t|����dS|�|��t�d|��|j	s|t|����dS|�	��|���}t�d|��|t|����dS)z�List server software plugins.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param plugins: List of plugins
    :type plugins: plugins_disco.PluginsRegistry

    :returns: `None`
    :rtype: None

    zExpected interfaces: %sNzFiltered plugins: %rFr+zPrepared plugins: %s)r�r��ifaces�visible�	functools�partialr1r2�init�preparer��	available)r'rTrp�filteredrBrvs      r4�plugins_cmdrxvsE���L�L�*�F�M�:�:�:��=�(�R�R�f�m�F���� � �'�'��/�/�H�
�L�L�'��2�2�2�
�
�|�8��
F�
F�
F�F��;��v�~����s�8�}�}�������M�M�&����
�L�L�'��2�2�2��>����s�8�}�}�������������"�"�$�$�I�
�L�L�'��3�3�3�
�F�3�y�>�>�����r6c���gd�}t�fd�|D����}tj���s=|s;d}t�|t
j��tjd���	tj
�|d��\}}n+#tj$r}t|��cYd}~Sd}~wwxYwtj
�|��stjd���d}tj�dd	|�
��d�_tj��j��}	|	�tjd����jr|	}
n-d
}t+j|	|��}
|
stjd���tj��j��}|stjd����js|j�_|r/t3�d|���}
|
�|
�jd	���tj���rtj||
|���dS)a6Add security enhancements to existing configuration

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param plugins: List of plugins
    :type plugins: plugins_disco.PluginsRegistry

    :returns: `None` or a string indicating an error
    :rtype: None or str

    )�hsts�redirect�uir�staplec3�8�K�|]}t�|��V��dSr)�getattr)r��enhr's  �r4�	<genexpr>zenhance.<locals>.<genexpr>�s-�����N�N��w�v�s�+�+�N�N�N�N�N�Nr6z|Please specify one or more enhancement types to configure. To list the available enhancement types, run:

%s --help enhance
z#No enhancements requested, exiting.�enhanceNrZzFWhich certificate would you like to use to enhance your configuration?FrWrzBCould not find the list of domains for the given certificate name.zJWhich domain names would you like to enable the selected enhancements for?zAUser cancelled the domain selection. No domains defined, exiting.z:Could not find the lineage for the given certificate name.r[)�redirect_default)�anyr&rcr��errorrrqr�MisconfigurationErrorr\r]r^r�r`rarr_r9r�rI�noninteractive_moder��
choose_valuesr�r�r"rQre)r'rT�supported_enhancements�oldstyle_enhr�r�rfrrh�cert_domainsr8�domain_questionr:r7s`             r4r�r��sj���C�B�B���N�N�N�N�7M�N�N�N�N�N�L��%�f�-�-�R�l�R�N�����S�#�/�*�*�*��*�+P�Q�Q�Q���;�F�G�Y�W�W��	�1�1���&�����1�v�v�
�
�
�
�
�
����������%�f�i�8�8�V��&�(U�V�V�	V�/��"�0��	�%�'�)�)�)�)*�,�F�O� �4�V�V�_�M�M�L����l�_�`�`�`�
�!�4����8���+�L�/�J�J���	4��,� 3�4�4�
4��/����H�H�G��Y��l�W�X�X�X���/�#�.����U�#�F�$�)�T�T�T�	�� � ��&�*;�e� �T�T�T��!�&�)�)�A���G�W�i��@�@�@��4s�3B
�
B5�B0�*B5�0B5c�H�tj|j|j||��dS)aRollback server configuration changes made during install.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param plugins: List of plugins
    :type plugins: plugins_disco.PluginsRegistry

    :returns: `None`
    :rtype: None

    N)r
�rollbackr��checkpoints)r'rTs  r4r�r��s&���O�F�$�f�&8�&�'�J�J�J�J�Jr6c�.�tj|��dS)a�Update the certificate file family symlinks

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

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: plugins_disco.PluginsRegistry

    :returns: `None`
    :rtype: None

    N)r�update_live_symlinks�r'r#s  r4�update_symlinksr��s��"�%�f�-�-�-�-�-r6c�.�tj|��dS)aZRename a certificate

    Use the information in the config file to rename an existing
    lineage.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: plugins_disco.PluginsRegistry

    :returns: `None`
    :rtype: None

    N)r�rename_lineager�s  r4�renamer�s��"���'�'�'�'�'r6c�.�tj|��dS)aZDelete a certificate

    Use the information in the config file to delete an existing
    lineage.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: plugins_disco.PluginsRegistry

    :returns: `None`
    :rtype: None

    N)rrr�s  r4rrs��"�������r6c�.�tj|��dS)a.Display information about certs configured with Certbot

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: plugins_disco.PluginsRegistry

    :returns: `None`
    :rtype: None

    N)r�certificatesr�s  r4r�r�(s����f�%�%�%�%�%r6c�l�dx|_|_|j�h|jrat	jt	j||j��|��}|j|_|jr tj	d��s|j|_n)|jr|jr|jrtjd���|j��t�d|j|j��tj|j|j��t#|jd��5}t$j�|�����}ddd��n#1swxYwYt-j||��}nRt�d|j��t1|��\}}t-j||j|j��}t#|jd��5}tj|�����d}ddd��n#1swxYwYt�d|j��	|�t%j|��|j��t?|��n+#t@j!$r}	tE|	��cYd}	~	Sd}	~	wwxYwtGj$|j��dS)	aSRevoke a previously obtained certificate.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: plugins_disco.PluginsRegistry

    :returns: `None` or string indicating error in case of error
    :rtype: None or str

    Nr)zCError! Exactly one of --cert-path or --cert-name must be specified!z$Revoking %s using certificate key %s�rbzRevoking %s using Account KeyrzReason code for revocation: %s)%r�r�r�r9r�
RenewableCertrr)rrYrrIr�r�r�r�verify_cert_matches_priv_key�open�jose�JWKr��readr
�acme_from_config_keyr�keyr+�pyopenssl_load_certificate�reason�revoke�ComparableX509r�acme_errors�ClientErrorr�r��success_revocation)
r'r#r:�fr�r�r�rfrOrs
          r4r�r�9s���/3�2�F��v�+�
���F�O���'��-�f�f�o�F�F��P�P��"�,����>�	+�#�.��":�":�	+�#�N�F�M��
�
�b�&�"2�b�v��b��l�`�a�a�a�
��"����;��%�v��	8�	8�	8��0��1A�6�?�S�S�S�
�&�/�4�
(�
(�	*�A��(�-�-������)�)�C�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*��*�6�3�7�7������4�f�6F�G�G�G�#�F�+�+���Q��*�6�3�7�C�H�E�E��	
�f���	%�	%�C���5�a�f�f�h�h�?�?��B��C�C�C�C�C�C�C�C�C�C�C����C�C�C�C�
�L�L�1�6�=�A�A�A�����D�'��-�-�v�}�=�=�=��v�&�&�&�&���"�����1�v�v�
�
�
�
�
�
����������"�6�#3�4�4�4��4sB�2E�E
�
E
�-H�H�H�3<I0�0J�?J�
J�Jc�:�	tj||d��\}}n+#tj$r}t	|��cYd}~Sd}~wwxYw|jr5|r3d|���vrtjd|j�d����tj
||��stjd���t|||��}t||��\}}t|||��\}}	|	}
|rt|||||	��}
|
r|
jnd}|
r|
jnd}|
r|
jnd}
|rt%||||
��d}	t'||||
��tj|��r|
rtj|
|||��|	�|st-j|��nt-j|��n#tj$r}|}Yd}~nd}~wwxYwt5|||
|���|r|�n#t5|||
|���|r|�wxYwt7|��t9j||j��dS)z�Obtain a certificate and install.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param plugins: List of plugins
    :type plugins: plugins_disco.PluginsRegistry

    :returns: `None`
    :rtype: None

    rzNzstaple-ocspz_Must-Staple extension requested, but OCSP stapling is not supported by the selected installer (a�)

You can either:
 * remove the --must-staple option from the command line and obtain a certificate without the Must-Staple extension, or;
 * use the `certonly` subcommand and manually install the certificate into the  intended service (e.g. webserver). You must also then manually enable OCSP stapling, as it is required for certificates with the Must-Staple extension to function properly.
 * choose a different installer plugin (such as --nginx or --apache), if possible.rZ�r�)r\r]rr^r��must_stapler�rar�r&r`r"r�r�rNr�r�r�r�rSrcrer��success_installation�success_renewalrIr�r5r�handle_subscriptionr)r'rTr�r�rr7r8r9�should_get_certr:�new_lineager�r�r�r�s               r4rzrzps�� �#+�#G��PW�Y^�#_�#_� �	�=�=���&�����1�v�v�
�
�
�
�
�
�����������
�i�
�M��Aa�Aa�Ac�Ac�,c�,c��&�	
a� �*�	
a�	
a�	
a�
�
�	
��%�f�i�8�8�V��&�(U�V�V�	V� ��
�y�A�A�I�1�&�)�D�D��G�X�)�&�'�8�D�D��O�W��K���(��F�G��g����*5�>��%�%�$�I�3>�H�[�/�/�D�N�'2�<�{�#�#��H��F����N�H�E�E�E�-1�M� ��f�i��+�>�>�>��%�f�-�-�	I�+�	I����W�i��H�H�H��?�/�?��,�W�5�5�5�5��'��0�0�0����<�����
�
�
�
�
�
���������	�6�=�+�/>�	@�	@�	@�	@��	 ���	 ��	�6�=�+�/>�	@�	@�	@�	@��	 �������$�V�,�,�,���F�I�$5�6�6�6��4sH��A�?�A�A�3A,F �G� F;�/F6�1G�6F;�;G�G/c	�b�|j\}}tj|j��}t	jd�|jrdndtj	|�������|�
|��\}}|jr"t�d|j
��dS|�||tj�|j
��tj�|j��tj�|j����\}}}	|||	fS)a@Obtain a cert using a user-supplied CSR

    This works differently in the CSR case (for now) because we don't
    have the privkey, and therefore can't construct the files for a lineage.
    So we just save the cert & chain to disk :/

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param client: Client object
    :type client: client.Client

    :returns: `cert_path`, `chain_path` and `fullchain_path` as absolute
              paths to the actual files, or None for each if it's a dry-run.
    :rtype: `tuple` of `str`

    r<r?r@r=z*Dry run: skipping saving certificate to %s�NNN)�
actual_csrr�get_names_from_req�datar1rBrCrDrErF�obtain_certificate_from_csrr�r�r��save_certificater$rl�normpathr�r�)
r'r7r�rf�	csr_namesrO�chainr�r�r�s
          r4�_csr_get_and_save_certr��s,��(�
�F�C���.�s�x�8�8�I��� �'�'�9?��/�5�5�.�)�?�	�J�J�	(�	
�	
�����7�7��<�<�K�D�%�
�~� ����8�&�:J�	L�	L�	L���,5�,F�,F��e�R�W�%�%�f�&6�7�7�
�����*�+�+�R�W�-=�-=�f�>S�-T�-T�-V�-V�)�I�z�>��j�.�0�0r6c�R�tj||d��\}}t|||��}t|||���}|st	jd���|rP|jsKtj|||��tj
d|j�d���|���dSdSdS)a�Renew & save an existing cert. Do not install it.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param plugins: List of plugins
    :type plugins: plugins_disco.PluginsRegistry

    :param lineage: Certificate lineage object
    :type lineage: storage.RenewableCert

    :returns: `None`
    :rtype: None

    :raises errors.PluginSelectionError: MissingCommandlineFlag if supplied parameters do not pass

    r{)r:z>An existing certificate for the given name could not be found.z
Reloading z! server after certificate renewalN)
r\r]r"rNrrIrDr�run_renewal_deployerr1rBr��restart)r'rTr:r��authr7�renewed_lineages       r4rHrH�s���(�:�6�7�J�W�W�O�I�t����i�8�8�I�(��F�G�L�L�L�O��]��l�[�\�\�\�������$�V�_�i�H�H�H���\��)9�\�\�\�]�]�]���������	���r6c��tj||d��\}}t|||��}|jrjt	||��\}}}t||||��t
|dd|j���t|��tj
||j��dSt||��\}}	t|||	��\}
}|
stjdd���dSt!||||	|��}d}|r]|r[|jsTt"�d|j��	|���n#t*j$r}
|
}Yd}
~
nd}
~
wwxYw|r|jnd}|r|jnd}|r|jnd}t5||||��t
||||
o|j���|r|�t|��tj
||j��dS)aAuthenticate & obtain cert, but do not install it.

    This implements the 'certonly' subcommand.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param plugins: List of plugins
    :type plugins: plugins_disco.PluginsRegistry

    :returns: `None`
    :rtype: None

    :raises errors.Error: If specified plugin could not be used

    r{Nr�z5Certificate not yet due for renewal; no action taken.Fr+z.Reloading %s server after certificate issuance)r\r]r"r�r�r�r�rDr5rr�rr�r�r1r2rNr�r�r�r�rrIr�r�r�r�)r'rTr�r�r7r�r�r�r8r9r�r:r�rr�s               r4r{r{sE��&�:�6�7�J�W�W�O�I�t����i�8�8�I�
�z��0F�v�y�0Y�0Y�-�	�:�~��V�Y�
�N�K�K�K��6�4��v�~�CU�V�V�V�V�(��0�0�0����	�(9�:�:�:���1�&�)�D�D��G�X�)�&�'�8�D�D��O�W����!�"Y�+0�	2�	2�	2�	2��� ��F�G�X�w�O�O�G�-1�M���9��V�^�����D�f�FV�W�W�W�	����������|�	�	�	��M�M�M�M�M�M�����	����&-�6��!�!�$�I�/6�@�W�+�+�D�N�#*�4�w����H��V�Y���A�A�A��v�}�g�+:�+Q�6�>�?Q�S�S�S�S�����$�V�,�,�,���F�I�$5�6�6�6�6�6s�D3�3E�E	�	Ec��	tj|��tj��dS#tj��wxYw)aRenew previously-obtained certificates.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: plugins_disco.PluginsRegistry

    :returns: `None`
    :rtype: None

    N)r�handle_renewal_requestr�run_saved_post_hooksr�s  r4r*r*NsB��%��&�v�.�.�.�
�"�$�$�$�$�$���"�$�$�$�$���s	�+�Ac�n�tj|jtj|j��t
jd��5tj|jtj|j��ddd��n#1swxYwY|j	|j
|jf}|D]}tj||j����dS)z�Create or verify existence of config, work, and hook directories.

    :param config: Configuration object
    :type config: configuration.NamespaceConfig

    :returns: `None`
    :rtype: None

    �N)�strict)
r�set_up_core_dir�
config_dirr�CONFIG_DIRS_MODE�strict_permissionsr"�
temp_umask�work_dir�renewal_pre_hooks_dir�renewal_deploy_hooks_dir�renewal_post_hooks_dir�make_or_verify_dir)r'�	hook_dirs�hook_dirs   r4�make_or_verify_needed_dirsr�bs��	���*�I�,F��Ha�b�b�b�
�	�u�	%�	%�e�e���V�_�i�.H�&�Jc�d�d�d�e�e�e�e�e�e�e�e�e�e�e����e�e�e�e��-��0��.�1�I��L�L������1J�K�K�K�K�K�L�Ls�+A6�6A:�=A:c#�K�d}d}|jr6d|_ttjd��}tj|��}nJ|jrtjtj��}n$tj	tj|j
��}	|V�|r|���dSdS#|r|���wwxYw)z�Creates a display object appropriate to the flags in the supplied config.

    :param config: Configuration object

    :returns: Display object

    NT�w)r/r�r�r$�devnull�display_obj�NoninteractiveDisplayrrr��FileDisplayrV�close)r'�	displayerr�s   r4�make_displayerr�ys�����15�� �G�
�|�2�%)��"��r�z�3�'�'���5�g�>�>�	�	�	�	#�2��5�c�j�A�A�	�	��+��J��0�2�2�	�������	��M�M�O�O�O�O�O�	�	��7�	��M�M�O�O�O�O�	���s�B-�-C�cli_argsc���|stjdd�}tj��tj�d��dkrtj|��}tj
���}t�
dtj��t�
dtjd��t�
d|��t�
d	|��t!j��t%j||��}t)j|��}t!j��	tj|��t1|��n&#t2j$r|jt8kr�YnwxYwt;|��5}t=j|��|�||��cddd��S#1swxYwYdS)
z�Run Certbot.

    :param cli_args: command line to Certbot, defaults to ``sys.argv[1:]``
    :type cli_args: `list` of `str`

    :returns: value for `sys.exit` about the exit status of Certbot
    :rtype: `str` or `int` or `None`

    rjN�CERTBOT_SNAPPED�Truezcertbot version: %sz#Location of certbot entry point: %srz
Arguments: %rzDiscovered plugins: %r) rrrsr�pre_arg_parse_setupr$�environ�getr�prepare_env�
plugins_disco�PluginsRegistryr�r�r��certbot�__version__r#�prepare_virtual_consoler�prepare_and_parse_argsr�NamespaceConfig�+raise_for_non_administrative_windows_rights�post_arg_parse_setupr�rrI�funcrxr�r��set_display)r�rT�argsr'r�s     r4�mainr��s���� ��8�A�B�B�<�������	�z�~�~�'�(�(�F�2�2��*�8�4�4���+�4�4�6�6�G�
�L�L�&��(;�<�<�<�
�L�L�6�����D�D�D�
�L�L��(�+�+�+�
�L�L�)�7�3�3�3�	� �"�"�"��%�g�x�8�8�D�
�
*�4�
0�
0�F�	�4�6�6�6��� ��(�(�(�"�6�*�*�*�*���<�����;�+�%�%��&�%�����

��	�	�,�9���	�*�*�*��{�{�6�7�+�+�,�,�,�,�,�,�,�,�,�,�,�,����,�,�,�,�,�,s$�#E9�9 F�F�.*G%�%G)�,G)r�r)T)~�__doc__�
contextlibrrr�logging.handlers�loggingrr�typingrrrrrr	r
rrr�josepyr�r�r
�acme_clientrr�rr�r�rrrr�certbot._internalrrrrrrrrrrr�certbot._internal.displayrr�rE�certbot._internal.pluginsr r�r!r\�certbot.compatr"r#r$�certbot.displayr%r�r1�certbot.pluginsr&rt�	getLogger�__name__r�r�r5r!r�r�rN�boolr`rwr�r�r�r�r�r�r�r��	Installerr�rIr�r�r�r��Account�ClientV2rr�
Authenticatorr"r�r0r�rBrLr�rSrVrbrdrxr�r�r�r�rr�r�rzr�rHr{r*r�r�r�r��intr�r	r6r4�<module>rs,����&�%�%�%�%�%���������
�
�
�
���������������������������������������������������������������&�&�&�&�&�&�&�&�&�&�&�&�*�*�*�*�*�*�����!�!�!�!�!�!�������������������������%�%�%�%�%�%�*�*�*�*�*�*�!�!�!�!�!�!�$�$�$�$�$�$�'�'�'�'�'�'�!�!�!�!�!�!�#�#�#�#�#�#�!�!�!�!�!�!�%�%�%�%�%�%�)�)�)�)�)�)�%�%�%�%�%�%�%�%�%�%�%�%�8�8�8�8�8�8�C�C�C�C�C�C�<�<�<�<�<�<�;�;�;�;�;�;�%�%�%�%�%�%�������������.�.�.�.�.�.�0�0�0�0�0�0�(�(�(�(�(�(�)��
��	�8�	$�	$���]�-J��t�����6W[�BF�<�<�&�-�<��9V�<� (��c�� 3�<�FN�s�m�<� (��)>� ?�<�%�W�%:�;�<�<�<�<�~,�-�2O�,�07�0E�,�JN�,�,�,�,�^-'�
�(E�-'�)1�#��-'�&-�&;�-'�&+�3���9N�0O�+O�%P�-'�-'�-'�-'�`2/�=�+H�2/�,3�,A�2/�(-�c�8�G�<Q�3R�.R�(S�2/�2/�2/�2/�j&�m�&C�&�d�SV�i�&�#(��#����AV�8W�)W�#X�&�&�&�&�R,�}�4�,�t�C�y�,�TW�,��$���)>� ?�?�@�,�,�,�,�2(T��-�(T�8<�S�	�(T��(T����
�x��8M�/N� N�O�(T�(T�(T�(T�V�G�C�L�L���h�q�k��8�A�;��5��a��RV�WX�RY�IY�CZ�����
�C�
�(�3�-�
�C�
�
�
�
�$^�=�+H�$^�08��
�$^�IL�$^�08��
�$^�BF�$^�$^�$^�$^�R9=�(�(�m�&C�(�)1�*�2F�)G�(�(0��
�(�AF�t�C�y�RU�~�AV�(�(�(�(�Z48�L�L�}�<�L�X�V\�Vb�Mc�L� (��)>� ?�L�,0�L�<@�L�L�L�L�`OS�*�*�]�:�*�x�PS�}�*�%-�c�]�*�>F�s�m�*�W[�*�*�*�*�Z�m�&C�������#��!>�#�8�TW�=�#�%-�c�]�#�DL�S�M�#�VZ�#�#�#�#�LA�}�<�A�!�'�/�"*�;�+?�"@�#A�B�A�A�A�A�H1 �=�#@�1 �T�1 �1 �1 �1 �hK�M�9�K�#+�J�,D�#E�K�'�
�(<�=�K�BH�-�K�K�K�K�8(�}�4�(�,�<�(�AI�#��(�(�(�(�V�]�2��*�:��?G��}�����>3�=�8�3�#0�#@�3�EM�c�]�3�3�3�3�l,��6�,�#0�#@�,�EM�c�]�,�,�,�,�^�m�.K��/7��8M�/N��S[�\_�S`����� RV�@�@�-�7�@�F�M�@���9�@�/7��8M�/N�@�Z^�@�@�@�@�::�M�1�:�"�2�:�7?��}�:�:�:�:�z�M�$A��m�Fc�����$G�}�'D�G��G�G�G�G�#�
�5�#�&�6�#�;?�#�#�#�#�L=�M�1�=�"�2�=�7?��}�=�=�=�=�@
K�]�2�
K�]�=Z�
K�_c�
K�
K�
K�
K� .�M�9�.�$1�$A�.�FJ�.�.�.�.�((�=�0�(�(�8�(�=A�(�(�(�(�( �=�0� �(�8� �=A� � � � �(&��6�&�!.�!>�&�CG�&�&�&�&�"4�=�0�4�(�8�4�=E�c�]�4�4�4�4�nR�
�-�R��.�R�3;�C�=�R�R�R�R�j%1�=�#@�%1�&,�m�%1�8=�#�C�=�(�3�-��#��F�9H�%1�%1�%1�%1�P �}�4� �}�?\� ��-� �26� � � � �F;7�]�2�;7�]�=Z�;7�_c�;7�;7�;7�;7�|%�-�/�%�'�7�%�<@�%�%�%�%�(L�}�'D�L��L�L�L�L�.��=�8��!�%��(I�(3�(?�)@�#A�BF��#M�N�������>/,�/,�8�D��I�&�/,�(�5��c��?�2K�/,�/,�/,�/,�/,�/,r6