404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.188.178.1: ~ $
3

گa���@s:dZddlmZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZddlmZdd	lm
Z
dd
lmZddlmZddlZddlZddlZddlZddlmZdd
lmZddlZddlmZddlmZdd
lmZddlmZddlmZddl 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-m.Z/ddl-mZ0ddl1m2Z3dd l1m4Z5dd!l6m7Z7dd"l6m8Z8dd#l6m9Z9dd$l:m;Z<ddl:mZ=dd%l>m?Z?d&Z@ejAeB�ZCejDdd'�d(d)�ZEd�ejFejDeeeGeeGee+jHee+jHd*�d+d,�ZIejDe+jHdd-�d.d/�ZJejDe
eGe+jHe
eGee+jHfd0�d1d2�ZKejDe+jHe
eGee+jHfd3�d4d5�ZLejDeeGe
eeGee+jHfd6�d7d8�ZMejDeeGeGe
eNee+jHfd9�d:d;�ZOejDeeGeGe
eeGee+jHfd9�d<d=�ZPed>�ZQe
eQe
eQe
eeQeeQfd?�d@dA�ZReGe
eGeGdB�dCdD�ZSejDe
eGeGe
eGddE�dFdG�ZTd�ejDeejUeeGe
eeGeGfdH�dIdJ�ZVd�ejDeejWee+jHeNddL�dMdN�ZXd�ejDeeGeeGeeGddO�dPdQ�ZYejDeNd'�dRdS�ZZejDeeGeeGeeGddT�dUdV�Z[ejDe
e!j\eej]fd'�dWdX�Z^ejDdd'�dYdZ�Z_ejDeej`eejUejFd[�d\d]�ZaejDe3jbeeGd^�d_d`�ZcejDe3jbeeGd^�dadb�ZdejDe3jbeeGd^�dcdd�ZeejDee+jHeeGd3�dedf�Zfd�ejDejFeeGee+jHddg�dhdi�ZgejDe3jbeeGdj�dkdl�ZhejDejDd'�dmdn�ZiejDdd'�dodp�ZjejDe3jbddj�dqdr�ZkejDe3jbeeGdj�dsdt�ZlejDe3jbddj�dudv�ZmejDe3jbdd^�dwdx�ZnejDe3jbdd^�dydz�ZoejDe3jbdd^�d{d|�ZpejDe3jbdd^�d}d~�ZqejDe3jbeeGd^�dd��ZrejDe3jbeeGdj�d�d��ZsejDejFe
eeGeeGeeGfd��d�d��ZtejDe3jbe+jHdd��d�d��ZuejDe3jbddj�d�d��ZvejDe3jbdd^�d�d��ZwejDdd'�d�d��ZxeejDeee=jye=jzfddfd'�d�d���Z{d�eeGeeeGe|fd��d�d��Z}dS)�zCertbot main entry point.�)�contextmanagerN)�	Generator)�IO)�Iterable)�List)�Optional)�Tuple)�TypeVar)�Union)�client)�errors)�
configuration)�crypto_util)�
interfaces)�util)�account)�cert_manager)�cli)�	constants)�eff)�hooks)�log)�renewal)�reporter)�snap_config)�storage)�updater)�obj)�disco)�	selection)�
filesystem)�misc)�os)�ops)�enhancementsz?User chose to cancel the operation and may reinvoke the client.)�config�returncCs4|jdkst�|js|jrdStjtjddd�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�AssertionErrorZstaging�quietr�atexit_register�display_util�notification)r%�r/�/usr/lib/python3.6/main.py� _suggest_donation_if_appropriate=sr1)�	le_clientr%�domains�certname�lineager&cCs�tj|�z�|dk	rRtjdj|jr&dndtj|p6|j��d��t	j
||||�np|dkrdtjd��tjdj|jrvdndtj|�d��|j
||�}|d	kr�tjd
��|dk	r�tj||j�|j�Wdtj|�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: 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

    Nz{action} for {domains}z-Simulating renewal of an existing certificatez Renewing an existing certificate)�actionr3z5Domain list cannot be none if the lineage is not set.z Simulating a certificate requestzRequesting a certificateFz!Certificate could not be obtained)rZpre_hookr-�notify�format�dry_run�internal_display_util�summarize_domain_list�namesr�
renew_certr�ErrorZobtain_and_enroll_certificateZdeploy_hook�live_dirZ	post_hook)r2r%r3r4r5r/r/r0�_get_and_save_certWs,



r@)r%�certr&cCsVtjd�stjd�rR|jj�}|jj�}||krRd}|j|j||�}tj|��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
    �key_typer4z�Are you trying to change the key type of the certificate named {0} from {1} to {2}? Please provide both --cert-name and --key-type on the command line to confirm the change you are trying to make.N)	r�
set_by_clirB�upperZprivate_key_typer8�lineagenamerr>)r%rAZnew_key_typeZcur_key_type�msgr/r/r0�%_handle_unexpected_key_type_migration�s	

rG)r%r3rAr&cCs�t||�dj|j��}dj|jj|dj|�tjd�}|jsV|j	sVt
j|ddddd�r^d	|fSt
jd
j|t
jdjtjdd
��tjd��tjt��d
S)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`

    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)�cli_flag�force_interactiver'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)rG�joinr<r8�
configfile�filenamer"�linesep�expandZrenew_by_defaultr-�yesnor7r�cli_command�sys�argvrr>�USER_CANCELLED)r%r3rAZexisting�questionr/r/r0�_handle_subset_cert_request�s 

rY)r%r5r&cCs�t||�|j�sd|fStj||�r.d|fS|jr<d|fSdj|jjtj	d�}|j
dkr`d}n|j
dkrnd}|d	g}tj||d
dd�}|d
tj
kr�tjd
��|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: 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?)rH�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)�defaultrKz.Operation canceled. You may re-run the client.rMzThis is impossibleN)rGZensure_deployedrZshould_renewrZr8rOrPr"rQr)r-ZmenuZCANCELrr>r*)r%r5rXZkeep_opt�choicesZresponser/r/r0�_handle_identical_cert_request�s2



r_)r%r3r&cCsX|jr
dStj||�\}}|dkr.|dkr.dS|dk	r@t||�S|dk	rTt|||�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.

    �newcertN)r`N)r`N)NN)Z	duplicaterZfind_duplicative_certsr_rY)r%r3Zident_names_certZsubset_names_certr/r/r0�_find_lineage_for_domainss
ra)r%r3r4r&cCs.t|||�\}}|dkr"tjd�|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`

    rZz Keeping the existing certificate)�&_find_lineage_for_domains_and_certname�logger�info)r%r3r4r6r5r/r/r0�
_find_cert:s
recCs�|st||�Stj||�}|rp|rftj||�}|rft|�t|�krft||�t||||j��d|fSt||�S|rxdSt	j
dj|���dS)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`Nz}No certificate with name {0} found. Use -d to specify domains, or run certbot certificates to see possible certificate names.)r`N)rar�lineage_for_certname�domains_for_certname�setrG�_ask_user_to_confirm_new_namesr<r_r�ConfigurationErrorr8)r%r3r4r5Zcomputed_domainsr/r/r0rbSs 



rb�T)�after�beforer&cCs@tt|�t|��}tt|�t|��}|j�|j�||fS)zWGet lists of items removed from `before`
    and a lists of items added to `after`
    )�listrh�sort)rlrm�added�removedr/r/r0�_get_added_removed�s
rr)�	character�stringsr&cCs(|s
d}nddj|�}|j|tjd�S)z%Format list with given character
    z
{br}(None)z	{br}{ch} )ZchrH)rNr8r"rQ)rsrtZ	formattedr/r/r0�_format_list�sru)r%�new_domainsr4�old_domainsr&cCsX|jr
dSt||�\}}dj|td|�td|�tjd�}tj|dddd	�sTtj	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?�+�-)rHzUpdate certificaterIT)r]z2Specified mismatched certificate name and domains.)
Zrenew_with_new_domainsrrr8rur"rQr-rSrrj)r%rvr4rwrprqrFr/r/r0ri�s
ri)r%�	installerrXr&cCsVd}|j}|jr|j}n|r(tj||�}|s8tj||�}|rN|rNtjd��||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.)r4r3rrg�display_opsZchoose_namesrr>)r%rzrXr3r4r/r/r0�_find_domains_or_certname�s
r|T)r%�
installer_errr5�new_or_renewed_certr&c		s�g}|r.|jd�j�dtj�dt�|����|rr�jrD|jd�n.t��rb|jdtj�d��n�jsr|jd�|szdS�fd	d
�tj	dtj
fD�\}}}t||d�tj
d
�t|dd�x|D]}tj
d|���q�W|r�t�dS)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).

    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.Ncs&g|]}tjj�r�jr|nd�qS)�)rU�stdout�isattyr+)�.0�c)r%r/r0�
<listcomp>#sz&_report_next_steps.<locals>.<listcomp>�
)�endzNEXT STEPS:rz- )�appendrzrrT�!_cert_name_from_config_or_lineage�csr�_is_interactive_only_auth�preconfigured_renewalrZ
ANSI_SGR_BOLDZANSI_SGR_RESET�printr-r7)	r%r}r5r~ZstepsZbold_on�nlZbold_off�stepr/)r%r0�_report_next_steps�s2"


r�)r%�	cert_path�fullchain_path�key_pathr&cCs�|jrtjd�dS|r|s$td��d}|jr<t|�r<d}tjdj|tj|�j	�|r`dj|�nd||j
dkrrd	ndd
��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

    zThe dry run was successful.Nz No certificates saved to report.rz_
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:         {}
r[r�)r��expiryZkey_msg�renewal_msgr�)r9r-r7r*r�r�r8r�notAfter�dater))r%r�r�r�r�r/r/r0�_report_new_cert1s
r�cCs|jdkr|jdkrdSdS)zP Whether the current authenticator params only support interactive renewal.
    ZmanualNTF)�
authenticatorZmanual_auth_hook)r%r/r/r0r�^sr�)r%r��
chain_pathr�r&cCsN|jrtjd�dS|r|s$td��tj|�j�}tjdj||||d��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

    zThe dry run was successful.Nz No certificates saved to report.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�)r9r-r7r*rr�r�r8)r%r�r�r�r�r/r/r0�_csr_report_new_cerths
r�cstdd��fdd�}tj��}d}�jdk	r:|j�j�}n�|j�}t|�dkrltj|�}|sftj	d��|}n�t|�dkr�|d}n��j
dkr��jr�tj��_
y"t
j�||d�\}}tjd	�WnFtjk
r��Yn0tj	k
�rtjd
dd�tj	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: 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

    N)�terms_of_servicer&cs6�jr
dSdj|�}tj|ddd�}|s2tjd��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-tosT)rJrKz?Registration cannot proceed without accepting Terms of Service.)Ztosr8r-rSrr>)r�rF�result)r%r/r0�_tos_cb�sz#_determine_account.<locals>._tos_cbrMzNo account has been chosen.r)Ztos_cbzAccount registered.rT)�exc_infoz.Unable to register an account with ACME server)�strr�AccountFileStorage�load�find_all�lenr{Zchoose_accountrr>�email�register_unsafely_without_email�	get_emailr�registerr-r7ZMissingCommandlineFlagrc�debug�id)r%r��account_storage�acme�acc�accountsZ
potential_accr/)r%r0�_determine_account�s6





r�cs|j}|dkr&d}tj|ddddd�}|s.dS|js8t�|jsJtj|�|_tj	t
jtj||j�ddd�||j��y&tj
|�fd	d
�gdd
�dd
��Wnftjk
r�tjd
��dStk
�r�}z(d}|j|j|j�|�}tj|��WYdd}~XnXtj|�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)ZNoT)�	yes_label�no_labelrKr]zutf-8)�encodingZdefault_encodingcs�S)Nr/)�x)�archive_dirr/r0�<lambda>�sz(_delete_if_appropriate.<locals>.<lambda>cSs|jS)N)r�)r�r/r/r0r��scSs|jS)N)rE)r�r/r/r0r��szhNot 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})Zdelete_after_revoker-rSr�r*r4r�cert_path_to_lineagerZfull_archive_path�	configobjZ	ConfigObj�renewal_file_for_certnameZmatch_and_check_overlapsrZOverlappingMatchFoundrcZwarning�	Exceptionr8Zdefault_archive_dirr?r>�delete)r%Zattempt_deletionrF�er/)r�r0�_delete_if_appropriate�s6




r�)r%r�rzr&cCs>|dk	r"t|�\}}tjd|�nd\}}tj|||||d�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: %r)r�)NN)r�rcr�r�Client)r%r�rzr�r�r/r/r0�_init_le_clients
r�)r%�unused_pluginsr&c
Cs�tj|�}|j�}|sdSd}tj|dddd�}|s8dSt|�\}}tj||dd|d	�}|jsht	j
d
��|jj|j�tj|�}	|	j
|j�tjd�dS)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 to deactivate.zCAre you sure you would like to irrevocably deactivate your account?Z
DeactivateZAbortT)r�r�r]zDeactivation aborted.N)r�zACME client is not set.zAccount deactivated.)rr�r�r-rSr�rr�r�rr>Zdeactivate_registration�regrr�r7)
r%r�r�r��promptZwants_deactivater�r��	cb_clientZ
account_filesr/r/r0�
unregisters$




r�cCs&tj|�}|j�}|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 and 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�r/r/r0r�Gs
r�c	Cstj|�}|j�}|sdS|jdkr:|jr:tjdd�|_t|�\}}tj	||dd|d�}|j
sjtjd��f}|jr�dd�|jj
d	�D�}|jj}|j
j|jj|jjj|d
�d��|_|jj|d�|_|j||j
�|js�tjd
�ntj||�tjdj|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 and error
    :rtype: None or str

    z-Could not find an existing account to update.NF)Zoptional)r�zACME client is not set.cSsg|]}d|�qS)zmailto:r/)r�r�r/r/r0r��sz"update_account.<locals>.<listcomp>�,)Zcontact)�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r>�splitr�r�Zupdate_registration�updater�Zupdate_regrr-r7rZprepare_subscriptionr8)	r%r�r�r�r�r�r�Zacc_contactsZ
prev_regr_urir/r/r0�update_accountfs.

r�cCs@|r
|jS|jr|jSytj|�}|Stjk
r:YnXdS)N)rEr4rr�rr>)r%r5Z	cert_namer/r/r0r��s
r�)r%r2r3r5r&cCsF|r|n|}|jdk	st�|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�r*Zdeploy_certificater�r�r��enhance_config)r%r2r3r5Z
path_providerr/r/r0�
_install_cert�s
r�)r%�pluginsr&c
Cs$ytj||d�\}}Wn&tjk
r<}zt|�Sd}~XnX|joH|j}|jrt|rtd}tj	|dd|d�d|_t
j||�s�tjd��|jr�t
|�}nt
j|�r�tjd��|jr�|jr�t|�t||�\}}t|d|d	�}t|||�n
tjd
��t
j|��r tj||j�}	t
j|	|||�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_promptrzVOne 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�rzz�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�r4r�
get_certnamesr$�
are_supported�NotSupportedError�_populate_from_certname�
are_requestedrj�_check_certificate_and_keyr|r�r�rf�enable)
r%r�rz�_r�Zcustom_cert�certname_questionr3r2r5r/r/r0r��s4




r�cCsZtj||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.)rrfr4r��	namespacer�r�r�)r%r5r/r/r0r�s



r�cCsPtjjtj|j��s&tjdj|j���tjjtj|j	��sLtjdj|j	���dS)Nz-Error while reading certificate from path {0}z-Error while reading private key from path {0})
r"�path�isfiler �realpathr�rrjr8r�)r%r/r/r0r�s
r�cCs�tjd|j�|jdkrgn|j}|j�j|�}tjd|�tjtjdd�}|jrl|j	rl|t
|��dS|j|�|j|�}tjd|�|j	s�|t
|��dS|j	�|j�}tjd|�|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: %rF)r(zVerified plugins: %rzPrepared plugins: %s)
rcr��ifacesZvisible�	functools�partialr-r.ZinitZpreparer�Zverify�	available)r%r�r�Zfilteredr7Zverifiedr�r/r/r0�plugins_cmd s$

r�cs�ddddg}t�fdd�|D��}tj��rP|rPd}tj|tj�tjd��yt	j
�|d	�\}}Wn&tjk
r�}zt|�Sd
}~XnXtj
�|�s�tjd��d}tj�d	d
|d�d�_tj��j�}	|	d
kr�tjd���jr�|	}
n d}tj|	|�}
|
�stjd��tj��j�}|�s*tjd���j�s:|j�_|�r`t�d
|d�}
|
j|
�jd
d�tj���r|tj||
|��d
S)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

    ZhstsZredirectZuirZstaplec3s|]}t�|�VqdS)N)�getattr)r�Zenh)r%r/r0�	<genexpr>Wszenhance.<locals>.<genexpr>z|Please specify one or more enhancement types to configure. To list the available enhancement types, run:

%s --help enhance
z#No enhancements requested, exiting.�enhanceNzVOne ore more of the requested enhancements are not supported by the selected installerzFWhich certificate would you like to use to enhance your configuration?F)r�r�rzBCould 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�rz)Zredirect_default)�anyr$r�rc�errorrrTrZMisconfigurationErrorr�r�r�r�r�r�rr�r4rgr>�noninteractive_moder{Z
choose_valuesrfr�r�r�r�)r%r�Zsupported_enhancementsZoldstyle_enhrFrzr�r�r�Zcert_domainsr3Zdomain_questionr5r2r/)r%r0r�GsH




r�cCstj|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�rollbackrzZcheckpoints)r%r�r/r/r0r��s
r�cCstj|�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)rZupdate_live_symlinks)r%r�r/r/r0�update_symlinks�sr�cCstj|�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)rZrename_lineage)r%r�r/r/r0�rename�sr�cCstj|�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)rr�)r%r�r/r/r0r��sr�cCstj|�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�certificates)r%r�r/r/r0r��sr�c
Cs�d|_|_|jdkrV|jrVtjtj||j�|�}|j|_|jrttj	d�rt|j|_n|jsj|jrt|jrtt
jd��|jdk	r�t
jd|j|j�tj|j|j�t|jd��}tjj|j��}WdQRXtj||�}n,t
jd|j�t|�\}}tj||j|j�}t|jd��}tj|j��d}WdQRXt
jd|j�y |jtj|�|j�t|�Wn(t j!k
�r�}	zt"|	�Sd}	~	XnXt#j$|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

    N�serverzCError! 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)%rzr�r�r4r�
RenewableCertr�r�rrCrr>r�rcr�rZverify_cert_matches_priv_key�open�joseZJWKr��readrZacme_from_config_keyr��keyr�Zpyopenssl_load_certificate�reason�revokeZComparableX509r��acme_errorsZClientErrorr�r{Zsuccess_revocation)
r%r�r5�fr�r�r�r�rAr�r/r/r0r��s:


r�c)Cs�ytj||d�\}}Wn&tjk
r<}zt|�Sd}~XnXtj||�sTtjd��t|||�}t	||�\}}t
|||�\}}	|	}
|r�t|||||	�}
|
r�|
jnd}|
r�|
j
nd}|
r�|
jnd}
|r�t||||
�d}z�yZt||||
�tj|�o�|
�rtj|
|||�|	dk�s|�r&tj|�n
tj|�Wn*tjk
�r\}z
|}WYdd}~XnXWdt|||
|d�|�r||�Xt|�tj||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

    r[NzVOne ore more of the requested enhancements are not supported by the selected installer)r~)r�r�rr�r�r$r�r�r�r|rer@r�r�r�r�r�r�r�r{Zsuccess_installationZsuccess_renewalr>r�r1r�handle_subscriptionr)r%r�rzr�r�r2r3r4�should_get_certr5Znew_lineager�r�r�r}r/r/r0r[sF
r[)r%r2r&c
Cs�|j\}}tj|j�}tjdj|jr(dndtj	|�d��|j
|�\}}|jr`tjd|j
�dS|j||tjj|j
�tjj|j�tjj|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`

    z{action} for {domains}z Simulating a certificate requestzRequesting a certificate)r6r3z*Dry run: skipping saving certificate to %sN)NNN)Z
actual_csrrZget_names_from_req�datar-r7r8r9r:r;Zobtain_certificate_from_csrrcr�r�Zsave_certificater"r��normpathr�r�)
r%r2r�r�Z	csr_namesrA�chainr�r�r�r/r/r0�_csr_get_and_save_certbs 


"r�)r%r�r5r&cCsttj||d�\}}t|||�}t|||d�}|s:tjd��|rp|jrptj|||�t	j
d|j�d��|j�dS)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\)r5z>An existing certificate for the given name could not be found.z
Reloading z! server after certificate renewalN)
r�r�r�r@rr>r9rZrun_renewal_deployerr-r7rzZrestart)r%r�r5rz�authr2Zrenewed_lineager/r/r0r=�s
r=c
Cs tj||d�\}}t|||�}|jrpt||�\}}}t||||�t|dd|jd�t|�t	j
||j�dSt||�\}}	t
|||	�\}
}|
s�tjddd�dSt||||	|�}|r�|jnd}|r�|jnd}|r�|jnd}t||||�t|d||
�o|jd�t|�t	j
||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\N)r~z5Certificate not yet due for renewal; no action taken.F)r()r�r�r�r�r�r�r�r9r1rr�rr|rer-r.r@r�r�r�r�)
r%r�rzr�r2r�r�r�r3r4r�r5r�r/r/r0r\�s0r\c
Csztj|�Wdtj�XdS)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)rZhandle_renewal_requestrZrun_saved_post_hooks)r%r�r/r/r0r'�sr'cCsZtj|jtj|j�tj|jtj|j�|j|j|j	f}x|D]}tj
||jd�q>WdS)z�Create or verify existence of config, work, and hook directories.

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

    :returns: `None`
    :rtype: None

    )�strictN)rZset_up_core_dirZ
config_dirrZCONFIG_DIRS_MODEZstrict_permissionsZwork_dirZrenewal_pre_hooks_dirZrenewal_deploy_hooks_dirZrenewal_post_hooks_dirZmake_or_verify_dir)r%Z	hook_dirsZhook_dirr/r/r0�make_or_verify_needed_dirs�s

rc
csnd}d}|jr,d|_ttjd�}tj|�}n$|jr@tjtj�}ntj	tj|j
�}z
|VWd|rh|j�XdS)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"�devnullr-�NoninteractiveDisplayrUr��FileDisplayrK�close)r%�	displayerrr/r/r0�make_displayers
r)�cli_argsr&cCs6|stjdd�}tj�tjjd�dkr4tj|�}t	j
j�}tj
dtj�tj
dtjd�tj
d|�tj
d	|�tj�tj||�}tj|�}tjj|tj�tj�ytj|�t|�Wn"tjk
r�|j t!kr�YnXt"j#|�}tjj|tj$�t%j&|j'�t(|��}t)j*|�|j ||�SQRXdS)
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`

    rMNZCERTBOT_SNAPPED�Truezcertbot version: %sz#Location of certbot entry point: %srz
Arguments: %rzDiscovered plugins: %r)+rUrVrZpre_arg_parse_setupr"�environ�getrZprepare_env�
plugins_disco�PluginsRegistryr�rcr��certbot�__version__r!Zprepare_virtual_consolerZprepare_and_parse_argsr
�NamespaceConfig�zopeZ	componentZprovideUtilityrZIConfigZ+raise_for_non_administrative_windows_rightsZpost_arg_parse_setuprrr>�funcr�rZReporterZ	IReporterrr,Zprint_messagesr�display_objZset_display)r	r��argsr%Zreportrr/r/r0�main's6








r)NNN)N)T)N)N)N)~�__doc__�
contextlibrr�Zlogging.handlersZloggingrUZtypingrrrrrrr	r
r�Zjosepyr�Zzope.componentrZzope.interfacer�rZacme_clientrr�rr
rrrZcertbot._internalrrrrrrrrrrrrZcertbot._internal.displayrrr:Zcertbot._internal.pluginsrr
rr�Zcertbot.compatr r!r"Zcertbot.displayr#r{r-Zcertbot.pluginsr$rWZ	getLogger�__name__rcrr1r�r�r�r@rGrYr_ra�boolrerbrkrrruriZ	Installerr|r>r�r�r�r�ZAccountZClientV2r�r�Z
Authenticatorr�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r[r�r=r\r'rrrr�intrr/r/r/r0�<module>s
"<-3
 (
")*
'.+&E&,

%<4*5&<	&?6F"&"2

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 302 B 0644
__init__.cpython-36.pyc File 302 B 0644
account.cpython-36.opt-1.pyc File 13.29 KB 0644
account.cpython-36.pyc File 13.29 KB 0644
auth_handler.cpython-36.opt-1.pyc File 16.2 KB 0644
auth_handler.cpython-36.pyc File 16.29 KB 0644
cert_manager.cpython-36.opt-1.pyc File 14.98 KB 0644
cert_manager.cpython-36.pyc File 14.98 KB 0644
client.cpython-36.opt-1.pyc File 25.25 KB 0644
client.cpython-36.pyc File 25.25 KB 0644
constants.cpython-36.opt-1.pyc File 3.98 KB 0644
constants.cpython-36.pyc File 3.98 KB 0644
eff.cpython-36.opt-1.pyc File 4.45 KB 0644
eff.cpython-36.pyc File 4.45 KB 0644
error_handler.cpython-36.opt-1.pyc File 5.8 KB 0644
error_handler.cpython-36.pyc File 5.8 KB 0644
hooks.cpython-36.opt-1.pyc File 8.34 KB 0644
hooks.cpython-36.pyc File 8.34 KB 0644
lock.cpython-36.opt-1.pyc File 8.77 KB 0644
lock.cpython-36.pyc File 8.77 KB 0644
log.cpython-36.opt-1.pyc File 12.77 KB 0644
log.cpython-36.pyc File 12.85 KB 0644
main.cpython-36.opt-1.pyc File 43.5 KB 0644
main.cpython-36.pyc File 43.69 KB 0644
renewal.cpython-36.opt-1.pyc File 15.53 KB 0644
renewal.cpython-36.pyc File 15.53 KB 0644
reporter.cpython-36.opt-1.pyc File 2.85 KB 0644
reporter.cpython-36.pyc File 2.91 KB 0644
snap_config.cpython-36.opt-1.pyc File 4.04 KB 0644
snap_config.cpython-36.pyc File 4.04 KB 0644
storage.cpython-36.opt-1.pyc File 38.5 KB 0644
storage.cpython-36.pyc File 38.5 KB 0644
updater.cpython-36.opt-1.pyc File 4.18 KB 0644
updater.cpython-36.pyc File 4.18 KB 0644