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

�]H��@sdZddlmZddlZddlZddlZddlZddlZ	ddl
Zddlm
ZddlmZddlZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlm
Z
ddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddl"m#Z#ddl"m$Z$ddl"m%Z%ddl&m!Z'm(Z)ddl*m+Z,ddl*m-Z-ddl*m.Z/dZ0e�1e2�Z3dd�Z4d d!�Z5dpd"d#�Z6d$d%�Z7d&d'�Z8d(d)�Z9d*d+�Z:d,d-�Z;d.d/�Z<d0d1�Z=d2d3�Z>dqd4d5�Z?drd6d7�Z@d8d9�ZAd:d;�ZBd<d=�ZCd>d?�ZDd@dA�ZEdBdC�ZFdsdDdE�ZGdFdG�ZHdHdI�ZIdJdK�ZJdLdM�ZKdNdO�ZLdPdQ�ZMdRdS�ZNdTdU�ZOdVdW�ZPdXdY�ZQdZd[�ZRd\d]�ZSd^d_�ZTd`da�ZUdbdc�ZVddde�ZWdfdg�ZXdhdi�ZYdjdk�ZZdtdldm�Z[e2dnk�re[�Z\e\�r�e3�]doe\�e�^e\�dS)uzCertbot main entry point.�)�print_functionN)�errors)�Union)�account)�cert_manager)�cli)�client)�
configuration)�	constants)�crypto_util)�eff)�hooks)�
interfaces)�log)�renewal)�reporter)�storage)�updater)�util)�
filesystem)�misc)�os)r�ops)�disco)�enhancements)�	selectionz?User chose to cancel the operation and may reinvoke the client.cCs<|jdkst�|jrdStj�tj�}d}|�||j	�dS)z�Potentially suggest a donation to support Certbot.

    :param config: Configuration object
    :type config: interfaces.IConfig

    :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-le

)
�verb�AssertionErrorZstaging�zope�	component�
getUtilityr�	IReporter�add_message�LOW_PRIORITY)�config�
reporter_util�msg�r(�./usr/lib/python3/dist-packages/certbot/main.py� _suggest_donation_if_appropriate1s
r*cCs2tj�tj�}|jdkst�|jd|jdd�dS)z�Reports on successful dry run

    :param config: Configuration object
    :type config: interfaces.IConfig

    :returns: `None`
    :rtype: None

    rzThe dry run was successful.F)Zon_crashN)	rr r!rr"rrr#�
HIGH_PRIORITY)r%r&r(r(r)�_report_successful_dry_runEs
�r,c	Cs�t�|�zz|dk	r0t�d�t�||||�nR|dk	s<t�t�d�|�||�}|dkrft	�
d��n|dk	r�t�||��|j
�W5t�|�X|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: interfaces.IConfig

    :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

    Nz Renewing an existing certificatezObtaining a new certificateFz!Certificate could not be obtained)r
Zpre_hookZ	post_hook�logger�infor�
renew_certrZobtain_and_enroll_certificater�ErrorZdeploy_hook�names�live_dir)�	le_clientr%�domains�certname�lineager(r(r)�_get_and_save_certUs


r7c
Cs�d�|���}dj|jj|d�|�tjd�}|jsV|jsVt	j
�tj
�j|ddddd�r^d	|fSt	j
�tj�}|�d
j|tjdd�tjd
d��tjd�|j�t�t��dS)a�Figure out what to do if a previous cert had a subset of the names now requested

    :param config: Configuration object
    :type config: interfaces.IConfig

    :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`

    z, 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?��brZExpand�Cancelz--expandT�Zcli_flag�force_interactiverz�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}r� �N)�joinr1�format�
configfile�filenamer�linesep�expandZrenew_by_defaultrr r!r�IDisplay�yesnor"r#�sys�argvr+rr0�USER_CANCELLED)r%r4�cert�existing�questionr&r(r(r)�_handle_subset_cert_request�s:��
����
rMcCs�|��sd|fSt�||�r$d|fS|jr2d|fSdj|jjtjd�}|j	dkrVd}n|j	dkrdd}|d	g}t
j�t
j�}|j||d
dd�}|d
tjkr�t�d
��n(|dd
kr�d|fS|ddkr�d|fStd��dS)a�Figure out what to do if a lineage has the same names as a previously obtained one

    :param config: Configuration object
    :type config: interfaces.IConfig

    :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`

    �	reinstallrz�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?r8�runz.Attempt to reinstall this existing certificate�certonlyz%Keep the existing certificate for nowz.Renew & replace the cert (limit ~5 per 7 days)rT)�defaultr<z.Operation canceled. You may re-run the client.r>zThis is impossibleN)Zensure_deployedrZshould_renewrNr@rArBrrCrrr r!rrEZmenu�display_utilZCANCELrr0r)r%r6rLZkeep_opt�choices�displayZresponser(r(r)�_handle_identical_cert_request�s@��

���rUcCsX|jr
dSt�||�\}}|dkr.|dkr.dS|dk	r@t||�S|dk	rTt|||�SdS)a�Determine 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: interfaces.IConfig

    :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.

    �ZnewcertNN�NN)Z	duplicaterZfind_duplicative_certsrUrM)r%r4Zident_names_certZsubset_names_certr(r(r)�_find_lineage_for_domains�s
rXcCs.t|||�\}}|dkr"t�d�|dk|fS)aWFinds an existing certificate object given domains and/or a certificate name.

    :param config: Configuration object
    :type config: interfaces.IConfig

    :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`

    rNz Keeping the existing certificate)�&_find_lineage_for_domains_and_certnamer-r.)r%r4r5�actionr6r(r(r)�
_find_cert
s
r[cCsz|st||�St�||�}|r^|rTtt�||��t|�krTt||||���d|fSt||�S|rfdSt�	d�
|���dS)a�Find appropriate lineage based on given domains and/or certname.

    :param config: Configuration object
    :type config: interfaces.IConfig

    :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.

    rrVz}No certificate with name {0} found. Use -d to specify domains, or run certbot certificates to see possible certificate names.N)rXr�lineage_for_certname�set�domains_for_certname�_ask_user_to_confirm_new_namesr1rUr�ConfigurationErrorr@)r%r4r5r6r(r(r)rY$s 
�
�rYcCs@tt|�t|��}tt|�t|��}|��|��||fS)zWGet lists of items removed from `before`
    and a lists of items added to `after`
    )�listr]�sort)ZafterZbefore�added�removedr(r(r)�_get_added_removedMs
recCs(|s
d}ndd�|�}|j|tjd�S)z%Format list with given character
    z
{br}(None)z	{br}{ch} )Zchr9)r?r@rrC)�	characterZstringsZ	formattedr(r(r)�_format_listWs�rgcCsf|jr
dSt||�\}}dj|td|�td|�tjd�}tj�t	j
�}|j|dddd	�sbt�
d
��dS)a�Ask user to confirm update cert certname to contain new_domains.

    :param config: Configuration object
    :type config: interfaces.IConfig

    :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?�+�-r8zUpdate certr:T)rQz+Specified mismatched cert name and domains.)Zrenew_with_new_domainsrer@rgrrCrr r!rrErFrr`)r%Znew_domainsr5Zold_domainsrcrdr'�objr(r(r)r_cs�r_cCsRd}|j}|jr|j}n|r(t�||�}|s8t�||�}|sJ|sJt�d��||fS)aRetrieve domains and certname from config or user input.

    :param config: Configuration object
    :type config: interfaces.IConfig

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

    :param `str` question: Overriding dialog 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.)r5r4rr^�display_opsZchoose_namesrr0)r%�	installerrLr4r5r(r(r)�_find_domains_or_certname�s
rmc	Cs�|jrt|�dS|r|s"td��t�|���}tj�t	j
�}|jdkrLdnd}|rddj|t
jd�nd}dj|||tj|t
jd�}|�||j�dS)	aDReports the creation of a new certificate to the user.

    :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

    Nz No certificates saved to report.rOz with the "certonly" option�z+Your key file has been saved at:{br}{0}{br}r8aCongratulations! Your certificate and chain have been saved at:{br}{0}{br}{1}Your cert will expire on {2}. To obtain a new or tweaked version of this certificate in the future, simply run {3} again{4}. To non-interactively renew *all* of your certificates, run "{3} renew")�dry_runr,rrZnotAfter�daterr r!rr"rr@rrCrZcli_commandr#�MEDIUM_PRIORITY)	r%�	cert_path�fullchain_path�key_pathZexpiryr&Z
verbswitchZprivkey_statementr'r(r(r)�_report_new_cert�s.����rucs��fdd�}t���}d}�jdk	r2|��j�}n�|��}t|�dkrRt�|�}n�t|�dkrh|d}nx�jdkr��js�t�	��_zt
j�||d�\}}WnDtj
k
r��Yn.tjk
r�tjddd	�t�d
��YnX|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: interfaces.IConfig

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

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

    csL�jr
dSd�|�j�}tj�tj�}|j|ddddd�}|sHt	�
d��dS)NTzhPlease read the Terms of Service at {0}. You must agree in order to register with the ACME server at {1}ZAgreer:z--agree-tosr;z?Registration cannot proceed without accepting Terms of Service.)Ztosr@Zserverrr r!rrErFrr0)Zterms_of_servicer'rj�result�r%r(r)�_tos_cb�s �
��z#_determine_account.<locals>._tos_cbNr>r)Ztos_cbrnT)�exc_infoz.Unable to register an account with ACME server)r�AccountFileStorage�load�find_all�lenrkZchoose_account�email�register_unsafely_without_email�	get_emailr�registerrZMissingCommandlineFlagr0r-�debug�id)r%rx�account_storage�acme�acc�accountsr(rwr)�_determine_account�s6



��
r�c
sDtj�tj�}tj�tj�}|j}|dkrBd}|j|ddddd�}|sX|�d|j	�dS|j
sbt�|jstt
�|�|_t�t�t�||j��||j��z&t
�|�fdd	�gd
d	�dd	��Wnztjk
r�d���}|�d
�|�|j�YdStk
�r4}z&d}|�|j|j�|�}t�|��W5d}~XYnXt
�|�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: interfaces.IConfig

    :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 ...
    NzmWould you like to delete the cert(s) you just revoked, along with all earlier and later versions of the cert?zYes (recommended)ZNoT)�	yes_label�no_labelr<rQzNot deleting revoked certs.cs�S�Nr(��x�Zarchive_dirr(r)�<lambda>>�z(_delete_if_appropriate.<locals>.<lambda>cSs|jSr�r�r�r(r(r)r�?r�cSs|Sr�r(r�r(r(r)r�?r�z^Not deleting revoked certs due to overlapping archive dirs. More than one lineage is using {0}rnz_config.default_archive_dir: {0}, config.live_dir: {1}, archive_dir: {2},original exception: {3})rr r!rrEr"Zdelete_after_revokerFr#r$rrrr5rZcert_path_to_lineagerZfull_archive_path�	configobjZ	ConfigObjZrenewal_file_for_certnameZmatch_and_check_overlapsrZOverlappingMatchFoundr@r?rq�	ExceptionZdefault_archive_dirr2r0�delete)r%rTr&Zattempt_deletionr'�er(r�r)�_delete_if_appropriatesH

�
���r�cCs>|dk	r"t|�\}}t�d|�nd\}}tj|||||d�S)anInitialize Let's Encrypt Client

    :param config: Configuration object
    :type config: interfaces.IConfig

    :param authenticator: Acme authentication handler
    :type authenticator: interfaces.IAuthenticator
    :param installer: Installer object
    :type installer: interfaces.IInstaller

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

    NzPicked account: %rrW�r�)r�r-r�r�Client)r%�
authenticatorrlr�r�r(r(r)�_init_le_clientNs
r�cCs�t�|�}|��}tj�tj�}|s(dStj�tj�j	}d}||dddd�}|sTdSt
|�\}}	tj||dd|	d	�}
|
j
�|j�t�|�}|�|j�|�d
|j�dS)z�Deactivate account on server

    :param config: Configuration object
    :type config: interfaces.IConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: `list` of `str`

    :returns: `None`
    :rtype: None

    z.Could not find existing account to deactivate.zCAre you sure you would like to irrevocably deactivate your account?Z
DeactivateZAbortT)r�r�rQzDeactivation aborted.Nr�zAccount deactivated.)rrzr|rr r!rr"rErFr�rr�r�Zdeactivate_registration�regrr�r#rq)r%�unused_pluginsr�r�r&rF�promptZwants_deactivater�r��	cb_clientZ
account_filesr(r(r)�
unregisteris&
�
r�cCsD|jrd}t�|�t||�St�|�}|��}|r8dSt|�dS)a$Create accounts on the server.

    :param config: Configuration object
    :type config: interfaces.IConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: `list` of `str`

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

    zuUsage 'certbot register --update-registration' is deprecated.
Please use 'certbot update_account [options]' instead.
zmThere is an existing account; registration of a duplicate account with this command is currently unsupported.N)�update_registrationr-�warning�update_accountrrzr|r�)r%r�r'r�r�r(r(r)r��s


r�c
s�t�|�}|��}tj�tj���fdd�}|s4dS|jdkrV|j	rHdSt
jdd�|_t|�\}}t
j||dd|d�}d	d
�|j�d�D�}|jj}	|j�|jj|jjj|d�d
��|_|jj|	d�|_|�||j�t�|�|d�|j��dS)a$Modify accounts on the server.

    :param config: Configuration object
    :type config: interfaces.IConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: `list` of `str`

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

    cs��|�j�Sr�)r#rq)�m�r&r(r)r��r�z update_account.<locals>.<lambda>z-Could not find an existing account to update.Nz�--register-unsafely-without-email provided, however, a new e-mail address must
currently be provided when updating a registration.F)Zoptionalr�cSsg|]}d|�qS)zmailto:r()�.0r~r(r(r)�
<listcomp>�sz"update_account.<locals>.<listcomp>�,)Zcontact)�body)�uriz'Your e-mail address was updated to {0}.)rrzr|rr r!rr"r~rrkr�r�rr��splitr�r�r�r��updater�Z	save_regrrZhandle_subscriptionr@)
r%r�r�r�Zadd_msgr�r�r�Zacc_contactsZ
prev_regr_urir(r�r)r��s,

�

r�cCsF|r|n|}|jdk	st�|�||j|j|j|j�|�||j�dS)a�Install a cert

    :param config: Configuration object
    :type config: interfaces.IConfig

    :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)rrrZdeploy_certificatert�
chain_pathrs�enhance_config)r%r3r4r6Z
path_providerr(r(r)�
_install_cert�s
�r�c

Cs*zt�||d�\}}Wn0tjk
rF}zt|�WY�Sd}~XYnX|joR|j}|jsz|szd}tj	|dd|d�d|_t
�||�s�t�d��|jr�t
|�}nt
�|�r�t�d��|jr�|jr�t|�t||�\}}t|d|d	�}t|||�n
t�d
��t
�|��r&t�||j�}	t
�|	|||�dS)z�Install a previously obtained cert in a server.

    :param config: Configuration object
    :type config: interfaces.IConfig

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

    :returns: `None`
    :rtype: None

    �installNz,Which certificate would you like to install?F�Zallow_multipleZ
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�rlz�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�PluginSelectionError�strrtrrr5r�
get_certnamesr�
are_supported�NotSupportedError�_populate_from_certname�
are_requestedr`�_check_certificate_and_keyrmr�r�r\�enable)
r%�pluginsrl�_r�Zcustom_cert�certname_questionr4r3r6r(r(r)r�s>
��




r�cCsZt�||j�}|s|S|js&|j|j_|js6|j|j_|jsF|j|j_|jsV|j|j_|S)zfHelper function for install to populate missing config values from lineage
    defined by --cert-name.)rr\r5rt�	namespacerrr�rs)r%r6r(r(r)r�;s



r�cCsPtj�t�|j��s&t�d�|j���tj�t�|j	��sLt�d�|j	���dS)Nz-Error while reading certificate from path {0}z-Error while reading private key from path {0})
r�path�isfiler�realpathrrrr`r@rtrwr(r(r)r�Ls��r�cCs�t�d|j�|jdkrgn|j}|���|�}t�d|�tjtj�t	j
�jdd�}|jsr|j
sr|t|��dS|�|�|�|�}t�d|�|j
s�|t|��dS|�
�|��}t�d|�|t|��dS)z�List server software plugins.

    :param config: Configuration object
    :type config: interfaces.IConfig

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

    :returns: `None`
    :rtype: None

    zExpected interfaces: %sNzFiltered plugins: %rF��pausezVerified plugins: %rzPrepared plugins: %s)r-r��ifacesZvisible�	functools�partialrr r!rrE�notificationZinitZpreparer�Zverify�	available)r%r�r�Zfiltered�notifyZverifiedr�r(r(r)�plugins_cmdSs,

��

r�c
shddddg}t�fdd�|D��}t���sP|sPd}t�|tjd�t�d	��zt	�
�|d
�\}}Wn0tjk
r�}zt|�WY�Sd}~XYnXt�
�|�s�t�d��d
}tj�d
d|d�d�_t���j�}	�jr�|	}
n d}t�|	|�}
|
�st�d��t���j�}�j�s"|j�_|�rHt�d|d�}
|
j|
�jdd�t����rdt�||
|��dS)z�Add security enhancements to existing configuration

    :param config: Configuration object
    :type config: interfaces.IConfig

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

    :returns: `None`
    :rtype: None

    ZhstsZredirectZuirZstaplecsg|]}t�|��qSr()�getattr)r�Zenhrwr(r)r��szenhance.<locals>.<listcomp>z|Please specify one or more enhancement types to configure. To list the available enhancement types, run:

%s --help enhance
rz#No enhancements requested, exiting.�enhanceNr�zFWhich certificate would you like to use to enhance your configuration?Fr�zJWhich domain names would you like to enable the selected enhancements for?zAUser cancelled the domain selection. No domains defined, exiting.r�)Zask_redirect)�anyrr�r-r�rGrHrZMisconfigurationErrorr�r�r�r�r�r�rr�r5r^�noninteractive_moderkZ
choose_valuesr0r\r�r�r�r�)r%r�Zsupported_enhancementsZoldstyle_enhr'rlr�r�r�Zcert_domainsr4Zdomain_questionr6r3r(rwr)r�zsJ


��
r�cCst�|j|j||�dS)z�Rollback server configuration changes made during install.

    :param config: Configuration object
    :type config: interfaces.IConfig

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

    :returns: `None`
    :rtype: None

    N)r�rollbackrlZcheckpoints)r%r�r(r(r)r��s
r�cCst�d�t�|�dS)aPShow changes made to server config during installation

    View checkpoints and associated configuration changes.

    :param config: Configuration object
    :type config: interfaces.IConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: `list` of `str`

    :returns: `None`
    :rtype: None

    zZThe config_changes subcommand has been deprecated and will be removed in a future release.N)r-r�rZview_config_changes�r%r�r(r(r)�config_changes�s
r�cCst�|�dS)arUpdate 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: interfaces.IConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: `list` of `str`

    :returns: `None`
    :rtype: None

    N)rZupdate_live_symlinksr�r(r(r)�update_symlinks�sr�cCst�|�dS)aARename a certificate

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

    :param config: Configuration object
    :type config: interfaces.IConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: `list` of `str`

    :returns: `None`
    :rtype: None

    N)rZrename_lineager�r(r(r)�rename�sr�cCst�|�dS)aADelete a certificate

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

    :param config: Configuration object
    :type config: interfaces.IConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: `list` of `str`

    :returns: `None`
    :rtype: None

    N)rr�r�r(r(r)r��sr�cCst�|�dS)aDisplay information about certs configured with Certbot

    :param config: Configuration object
    :type config: interfaces.IConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: `list` of `str`

    :returns: `None`
    :rtype: None

    N)r�certificatesr�r(r(r)r�s
r�c
Cs`d|_|_|jdkr.|jr.t�||j�|_n|jr@|jrJ|jrJt�d��|jdk	r�t	�
d|jd|jd�t�|jd|jd�t
j�|jd�}t�||�}n0t	�
d|jd�t|�\}}t�||j|j�}t�|jd�d}t	�
d|j�z |�t
�|�|j�t|�Wn2tjk
�rJ}zt|�WY�Sd}~XYnXt�|jd�dS)a:Revoke a previously obtained certificate.

    :param config: Configuration object
    :type config: interfaces.IConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: `list` of `str`

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

    NzCError! Exactly one of --cert-path or --cert-name must be specified!zRevoking %s using cert key %srr>zRevoking %s using Account KeyzReason code for revocation: %s)rlr�rrr5rZcert_path_for_cert_namerr0rtr-r�rZverify_cert_matches_priv_key�joseZJWKr{rZacme_from_config_keyr��keyr�Zpyopenssl_load_certificate�reason�revokeZComparableX509r��acme_errorsZClientErrorr�rkZsuccess_revocation)r%r�r�r�r�r�rJr�r(r(r)r�s2

�r�c
Cs:zt�||d�\}}Wn0tjk
rF}zt|�WY�Sd}~XYnXt�||�s^t�d��t|||�}t	||�\}}t
|||�\}}	|	}
|r�t|||||	�}
|
r�|
jnd}|
r�|
j
nd}|
r�|
jnd}
t||||
�t||||
�t�|��r|
�rt�|
|||�|	dk�s|�s$t�|�n
t�|�t|�dS)z�Obtain a certificate and install.

    :param config: Configuration object
    :type config: interfaces.IConfig

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

    :returns: `None`
    :rtype: None

    rONr�)r�r�rr�r�rr�r�r�rmr[r7rrrsrtrur�r�r�rkZsuccess_installationZsuccess_renewalr*)r%r�rlr�r�r3r4r5�should_get_certr6Znew_lineagerrrsrtr(r(r)rOKs6
�
rOc	Csn|j\}}|�|�\}}|jr0t�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: interfaces.IConfig

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

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

    z*Dry run: skipping saving certificate to %srW)Z
actual_csrZobtain_certificate_from_csrror-r�rrZsave_certificaterr��normpathr�rs)r%r3�csrr�rJ�chainrrrsr(r(r)�_csr_get_and_save_cert�s 
��
r�c	
Cs�zt�||d�\}}Wn2tjk
rH}zt�d|��W5d}~XYnXt|||�}t|||d�}tj	�
tj�j
}|dkr�|d�|j�dd�n.t�|||�|��|d�|j|j�dd�dS)	a�Renew & save an existing cert. Do not install it.

    :param config: Configuration object
    :type config: interfaces.IConfig

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

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

    :returns: `None`
    :rtype: None

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

    rP�'Could not choose appropriate plugin: %sN)r6z9new certificate deployed without reload, fullchain is {0}Fr�zDnew certificate deployed with reload of {0} server; fullchain is {1})r�r�rr�r-r.r�r7rr r!rrEr�r@Z	fullchainrZrun_renewal_deployerZrestartrl)	r%r�r6rl�authr�r3Zrenewed_lineager�r(r(r)r/�s,����r/c
Cszt�||d�\}}Wn2tjk
rH}zt�d|��W5d}~XYnXt|||�}|jr�t||�\}}t	|||�t
|�dSt||�\}}	t|||	�\}
}|
s�t
j�tj�j}|ddd�dSt||||	|�}|r�|jnd}|r�|jnd}|r�|jnd}
t	||||
�t
|�dS)afAuthenticate & obtain cert, but do not install it.

    This implements the 'certonly' subcommand.

    :param config: Configuration object
    :type config: interfaces.IConfig

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

    :returns: `None`
    :rtype: None

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

    rPr�Nz5Certificate not yet due for renewal; no action taken.Fr�)r�r�rr�r-r.r�r�r�rur*rmr[rr r!rrEr�r7rrrsrt)r%r�rlr�r�r3rrrsr4r5r�r6r�rtr(r(r)rP�s.rPcCszt�|�W5t��XdS)aRenew previously-obtained certificates.

    :param config: Configuration object
    :type config: interfaces.IConfig

    :param unused_plugins: List of plugins (deprecated)
    :type unused_plugins: `list` of `str`

    :returns: `None`
    :rtype: None

    N)r
Zrun_saved_post_hooksrZhandle_renewal_requestr�r(r(r)r�s
rcCsVt�|jtj|j�t�|jtj|j�|j|j|j	f}|D]}tj
||jd�q<dS)z�Create or verify existence of config, work, and hook directories.

    :param config: Configuration object
    :type config: interfaces.IConfig

    :returns: `None`
    :rtype: None

    )�strictN)rZset_up_core_dirZ
config_dirr
ZCONFIG_DIRS_MODEZstrict_permissionsZwork_dirZrenewal_pre_hooks_dirZrenewal_deploy_hooks_dirZrenewal_post_hooks_dirZmake_or_verify_dir)r%Z	hook_dirsZhook_dirr(r(r)�make_or_verify_needed_dirss
�r�cCsT|jr d|_t�ttjd��}n$|jr4t�tj�}nt�	tj|j
�}tj�
|�dS)z�Set the displayer

    :param config: Configuration object
    :type config: interfaces.IConfig

    :returns: `None`
    :rtype: None

    T�wN)�quietr�rRZNoninteractiveDisplay�openr�devnullrG�stdoutZFileDisplayr<rr �provideUtility)r%Z	displayerr(r(r)�
set_displayer s
�r�cCs|stjdd�}t��tj��}t�dt	j
�t�d|�t�d|�t�||�}t
�|�}tj�|�t��zt�|�t|�Wn"tjk
r�|jtkr��YnXtjdd�dkr�t�d�t|�t�|�}tj�|�t� |j!�|�||�S)	z�Command line argument parsing and main script execution.

    :returns: result of requested command

    :raises errors.Error: OS errors triggered by wrong permissions
    :raises errors.Error: error if plugin command is not supported

    r>Nzcertbot version: %sz
Arguments: %rzDiscovered plugins: %r�)��zgPython 3.4 support will be dropped in the next release of Certbot - please upgrade your Python version.)"rGrHrZpre_arg_parse_setup�
plugins_discoZPluginsRegistryr|r-r��certbot�__version__rZprepare_and_parse_argsr	ZNamespaceConfigrr r�rZ+raise_for_non_administrative_windows_rightsZpost_arg_parse_setupr�rr0�funcr��version_infor�r�rZReporterrZatexit_registerZprint_messages)Zcli_argsr��argsr%Zreportr(r(r)�main6s0	





r��__main__zExiting with message %s)NNN)N)N)N)N)_�__doc__Z
__future__rr�Zlogging.handlersZloggingrGr�Zjosepyr�Zzope.componentrr�rr�Zacme.magic_typingrr�rrrrr	r
rrr
rrrrrrrZcertbot.compatrrrZcertbot.displayrRrrkZcertbot.pluginsrr�rrr�rIZ	getLogger�__name__r-r*r,r7rMrUrXr[rYrergr_rmrur�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rOr�r/rPrr�r�r�Z
err_stringr��exitr(r(r(r)�<module>s�

/02')
%
)
*<7)&-
;';-7*1
3


Anon7 - 2021