M/e$dZddlmZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z ddlm Z ddlm Z dd lmZdd lmZdd lmZdd lmZddlZddlZddlZdd lmZddlmZddlmZddlmZddlZddlmZddlm Z ddlmZddlm!Z!ddlm"Z"ddl#m$Z$ddl#m%Z%ddl#m&Z&ddl#mZddl#m'Z'ddl#m(Z(ddl#m)Z)ddl#m*Z*ddl#m+Z+ddl#m,Z,ddl#m-Z-ddl#m.Z.dd l/m0Z1ddl/m"Z2dd!l3m4Z5dd"l3m6Z7dd#l8m9Z9dd$l8m:Z:dd%l8m;Z;dd&lddlZUd)ejd?e eId.eId@e eId*df dAZV dtd)ejdBee!jdCeeId*ee eIeIffdDZX dud)ejdEeejd/ee-jdFeLd*df dGZZ dtd)ejdHeeIdIeeIdJeeId*df dKZ[d)ejd*eLfdLZ\d)ejdHeeIdMeeIdIeeId*df dNZ]d)ejd*ee$jeejffdOZ`d)ejd*dfdPZad)ejdQee!jdBee!jd*ejfdRZcd)ejdSe5jd*eeIfdTZed)ejdSe5jd*eeIfdUZfd)ejdSe5jd*eeIfdVZgd)ejdSe5jd*eeIfdWZhd)ejd/ee-jd*eeIfdXZi dtd)ejd,ejd-e eId/ee-jd*df dYZjd)ejdZe5jd*eeIfd[Zkd)ejd*ejfd\Zld)ejd*dfd]Zmd)ejdZe5jd*dfd^Znd)ejdZe5jd*eeIfd_Zod)ejdZe5jd*dfd`Zpd)ejdSe5jd*dfdaZqd)ejdSe5jd*dfdbZrd)ejdSe5jd*dfdcZsd)ejdSe5jd*dfddZtd)ejdSe5jd*eeIfdeZud)ejdZe5jd*eeIfdfZvd)ejd,ejd*eeeIeeIeeIffdgZwd)ejdZe5jd/e-jd*dfdhZxd)ejdZe5jd*dfdiZyd)ejdSe5jd*dfdjZzd)ejd*dfdkZ{dleIdmejd*dfdnZ}d)ejdZe5jd*dfdoZ~ed)ejd*e ee1je1jfddffdpZdtdqee eId*eeeIeffdrZy)vzCertbot main entry point.)contextmanagerN)cast) Generator)IO)Iterable)List)Optional)Tuple)TypeVar)Union)b64)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.configreturnc|jdk7sJ|js |jrytjt j ddy)zPotentially suggest a donation to support Certbot. :param config: Configuration object :type config: configuration.NamespaceConfig :returns: `None` :rtype: None renewNzIf 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-leFpause)verbstagingquietratexit_register display_util notificationr(s 8/usr/lib/python3/dist-packages/certbot/_internal/main.py _suggest_donation_if_appropriater6?sH ;;' !! ! ~~!! K  le_clientdomainscertnamelineagec tj|g} |rtjdj |j rdndt j|xs|jtj||||n|tjdtjdj |j rdndt j||j||}|durtjd |@tj||j|j|j!|tj"|||S#tj"||wxYw) 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 {action} for {domains}z-Simulating renewal of an existing certificatez Renewing an existing certificateactionr9z5Domain list cannot be none if the lineage is not set. Simulating a certificate requestRequesting a certificateFz!Certificate could not be obtained)rpre_hookr2notifyformatdry_runinternal_display_utilsummarize_domain_listnamesr renew_certrErrorobtain_and_enroll_certificate deploy_hooklive_dirextend post_hook)r8r(r9r:r;renewed_domainss r5_get_and_save_certrQYs\8 NN6!#O1     (//~~K+M1GGHbSZS`S`Sbc0    vw 7 Cll#Z[[   (//AG=51GGP0  ==gxPG%ll#FGG"!!&'--/7;K;KL&&w/ 0 N 0s D?E00Fcertc |jj}|jj}||k(ry|jdxr|jd}|s.t j d|d|j d|ddd dd ry |jdr)tjd |j d |d|d|j|_y)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` Fkey_typer:zAn z certificate named z7 already exists. Do you want to update its key type to ?zUpdate key typezKeep existing key type) yes_labelno_labeldefaultforce_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.) rTupperprivate_key_type set_by_userr2yesno lineagenamerrJlower)r(rR new_key_type cur_key_typeis_confirmed_via_clis r5%_handle_unexpected_key_type_migrationrcs??((*L((..0L|#"--j9\f>P>PQ[>\|11 l^.t/?/?.@A"".q 2#.F   *%ll M |nDG& &  #((*FO r7c Jt||dj|j}dj|jj |dj|t j}|js&|jstj|ddddrd |fStjd j|tjd jtj d d t jt#j$t&)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?brExpandCancelz--expandTcli_flagrYr+zTo 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)rcjoinrHrD configfilefilenamer%linesepexpandrenew_by_defaultr2r]rCr cli_commandsysargvrrJUSER_CANCELLED)r(r9rRexistingquestions r5_handle_subset_cert_requestrzs(*&$7yy&H 0  fT__ % %  YYw     }}//<3E3E(HzT4S} 239&  OOSXXchhqrl3zz393   ,,~ &&r7c t||}|jsd|fS|stj||rd|fS|jrd|fSdj |j jtj}|jdk(rd}n|jdk(rd}d g}tj||d d }|d tjk(rtjd |dd k(rd|fS|ddk(rd|fSt!d)aFigure 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+zYou 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?rfrunz.Attempt to reinstall this existing certificatecertonlyz%Keep the existing certificate for nowzBRenew & replace the certificate (may be subject to CA rate limits)rT)rXrYz.Operation canceled. You may re-run the client.rmzThis is impossible)rcensure_deployedr should_renewr|rDrorpr%rqr.r2menuCANCELrrJAssertionError)r(r;is_key_type_changingrykeep_optchoicesresponses r5_handle_identical_cert_requestrs6 AQ  " " $G##w33FGD G## ; fW   ( (RZZf8  {{eC  ":SUG  7,-GH{l)))ll <> >{aG## !  - ..r7c|jrytj||\}}||y| t||S| t |||Sy)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. newcertNNN) duplicaterfind_duplicative_certsrrz)r(r9ident_names_certsubset_names_certs r5_find_lineage_for_domainsr/sh2*6*M*MfV]*^''$5$=#-f6FGG  &*67>   # #%BBH&BR TTr7Tafterbeforectt|t|z }tt|t|z }|j|j||fS)zWGet lists of items removed from `before` and a lists of items added to `after` )listrsort)rraddedremoveds r5_get_added_removedrsN Uc&k) *E3v;U+,G JJL LLN '>r7 characterstringscv|sd}nddj|z}|j|tjS)z%Format list with given character z {br}(None)z {br}{ch} )chrg)rnrDr%rq)rr formatteds r5 _format_listrsC  +"2"27";;     ::  r7 new_domains old_domainsc|jryt||\}}dj|td|td|tj }t j|ddd stjd y) 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 NzYou 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?+-rfzUpdate certificateriTrXz2Specified mismatched certificate name and domains.) renew_with_new_domainsrrDrr%rqr2r]rr)r(rr:rrrmsgs r5rrs.$$' [ANE7 117C'C)** 282   c#74 P''(\]] Qr7 installerrycd}|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 NzPlease specify --domains, or --installer that will help in domain names autodiscovery, or --cert-name for an existing certificate name.)r:r9rr display_ops choose_namesrrJ)r(rryr9r:s r5_find_domains_or_certnamers{(GH ~~.. 33FHE **9h? 8llKL L H r7 installer_errnew_or_renewed_certc Xg}|rx|jdk(r-|jd|jd|jdn<|jd|jdtjdt |||rj|j r|jdnLt|r$|jd tjd n|js|jd |sy tjd tjfDcgc]0}tjjr|js|nd2c}\}}}t!||t#j$dt!|d|D]} t#j$d| |r t!y y cc}w)aDisplays 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 zCertificates 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.zThis 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.zThe 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.N )endz NEXT STEPS:z- )r.appendrrrt!_cert_name_from_config_or_lineagecsr_is_interactive_only_authpreconfigured_renewalr ANSI_SGR_BOLDANSI_SGR_RESETrustdoutisattyr0printr2rC) r(rr;rstepscbold_onnlbold_offsteps r5_report_next_stepsr s(E ;;* $ LL$$%&EEKEUEUDVV`b  LLT##$%""%//!22G4VWEFH  :: LL) *'v . LL!__--[]  -- LLJ K *.););T4CVCV(WY#$%(JJ$5$5$7 qRTTYWb( 'r & ()bK() Ys5F' cert_pathfullchain_pathkey_pathc p|jrtjdy|r|sJdd}|jr t |sd}tjdj |t j|j|rdj |nd||jdk(rd nd y) aReports 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.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)rexpirykey_msg renewal_msgr) rEr2rCrrrDrnotAfterdater.)r(rrrrs r5_report_new_certrXs(~~9: K)KK 'K ##,Ef,M8  TV\U[$'' 2779HP3::8DVX#{{e+t V\V r7c<|jdk(r |jyy)zP Whether the current authenticator params only support interactive renewal. manualTF) authenticatormanual_auth_hookr4s r5rrs#x'F,C,C,K r7 chain_pathc|jrtjdy|r|sJdtj|j }tjdj ||||y)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 rNrz 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}.)rrrr)rEr2rCrrrrD)r(rrrrs r5_csr_report_new_certrsu$~~9: K)KK '  ! !) , 1 1 3F 028J)&282 r7cdtddffd }tj}d}j|jj}n|j }t |dkDr/t j|}|stjd|}nvt |dk(r|d}nbj%jst j_ tj||\}}tj d |j2_||fS#tj"$rtjt$jf$r}t&j)d d t%j*|r3t-j.t1t$j|}d |}n t|}tjd|d}~wwxYw)aDetermine 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)Ncjrydj|}tj|dd}|st j dy)NzpPlease read the Terms of Service at {0}. You must agree in order to register with the ACME server. Do you agree?z --agree-tosTrjz?Registration cannot proceed without accepting Terms of Service.)tosrDr2r]rrJ)rrresultr(s r5_tos_cbz#_determine_account.._tos_cbsW :: ''-v.>'? ##C-SWX,,$% %r7rmzNo account has been chosen.r)tos_cbzAccount registered.rT)exc_infoz#Error returned by the ACME server: z0Unable to register an account with ACME server. )strrAccountFileStorageloadfind_alllenrchoose_accountrrJemailregister_unsafely_without_email get_emailrregisterr2rCMissingCommandlineFlag acme_messagesrdebug is_acme_errorrFdescribe_acme_errorrid) r(raccount_storageacmeaccaccounts potential_accerrerr_msgs ` r5_determine_accountrs$ %# %$ %008O+/D ~~!""6>>2"++- x=1 '66x@M ll#@AAC ]a 1+C||#F,R,R*446  R"OOOG= T##$9:VVFN 900 LL-"5"56 R R$ / ..s33GG]00#68G CG9MG!#hGllFwiPRR Rs"0D''6G$BGG$c|j}|d}tj|dddd}|sy|jsJ|jst j ||_tjtjtj||jdd||j t j|fd gd d t j,|y#tj$rtj!d Yyt"$rD}d }|j%|j&|j(|}tj*|d}~wwxYw)aDoes 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)rVrWrYrXutf-8encodingdefault_encodingcSN)x archive_dirs r5z(_delete_if_appropriate..sr7c|jSr )rr s r5rz(_delete_if_appropriate..s  r7c|jSr )r^rs r5rz(_delete_if_appropriate..s QRQ^Q^r7zhNot 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_revoker2r]rr:rcert_path_to_lineagerfull_archive_path configobj ConfigObjrenewal_file_for_certnamematch_and_check_overlapsrOverlappingMatchFoundrwarning ExceptionrDdefault_archive_dirrMrJdelete)r(attempt_deletionrers @r5_delete_if_appropriater!sS11O'--c=P[_@DdT      ??&;;FC++   11&&//J 7 < FOO %K  --f7L6M.EG^ `  ' '?@K M  )jj33V__kSTUll3  s9C--)E$E$ ?EE$rc|%t|\}}tjd|nd\}}tj|||||S)aInitialize 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 zPicked account: %rrr)rrrrClient)r(rrrrs r5_init_le_clientr%-sG$ &v. T )3/ T ==mYT JJr7unused_pluginsctj|}|j}|sd|jdSd}t j |ddd}|syt |\}}tj||d d | }|jstjd |jj|jtj|} | j|jt jd y ) 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? DeactivateAbortT)rVrWrXzDeactivation aborted.Nr#ACME client is not set.zAccount deactivated.)rrrserverr2r]rrr$rrrJdeactivate_registrationregrrrC) r(r&rrpromptwants_deactivaterr cb_client account_filess r5 unregisterr3Is008O'')H >ll455NN**3884..v6M(./ r7cjtj|}|j}|ryt|y)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)rrrr)r(r&rrs r5rrts7 008O'')Hv r7ctj|}|j}|sd|jdS|j'|j st jd|_t|\}}tj||dd|}|jstjdd}|jr+|jjd Dcgc]}d |z }}|jj } |jj#|jj%|jj&j%|  |_|jj%| |_|j)||jst+j,dyt/j0||t+j,dj3|jycc}w)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 ,mailto:)contact)body)urizFAny contact information associated with this account has been removed.z'Your e-mail address was updated to {0}.)rrrr,rrrrrrr$rrrJsplitr.r<update_registrationupdater; update_regrr2rCrprepare_subscriptionrD) r(r&rrrrr1 acc_contactsr prev_regr_uris r5update_accountrDs 008O'')H ? aPP ||F$J$J",,e< "6*IC fc4DAI >>ll455#%L ||7=||7I7I#7NOe E)O OHHLLM~~11#((// XX]] ! !, ! 73B39:CH xx=1CH$ <<B C    -ELLV\\Z[ %Ps G:ctj|}|j}|sd|jdSt |\}}t j ||dd|}|jstjd|jj|j}d|jdd|jg}tj|jj!j#} |j%d | g} |j&j(D](} | j+d s| j%| d d*|j%d j-t/| d kDrdndt/| dkDrdj1| ndt3j4dj1|y)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 r6r(Nr#r+zAccount details for server :z Account URL: z Account Thumbprint: r9z Email contact{}: {}rmsrrrenoner)rrrr,rrr$rrrJquery_registrationr.r<r b64encodekey thumbprintdecoderr;r: startswithrDrrnr2rC) r(r&rrrrr1r.outputrMemailsr:s r5 show_accountrRs 008O'')H ? aPP"6*IC fc4DAI >>ll455 >> , ,SXX 6D+FMM?!<z*,Fsww1134;;=J MM*:,78 F99$$'   i ( MM'!"+ &' MM)00#&v;?C14VqDIIf-fNO &)* r7c|r |jS|jr |jS tj|}|S#tj $rYywxYwr )r^r:rrrrJ)r(r; cert_names r5rrsV"""   55f=  <<   s?AAc|r|n|}|jJ|j||j|j|j|j|j ||jy)aInstall 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)rdeploy_certificaterrrenhance_config)r(r8r9r; path_providers r5 _install_certrY sm*FM'RX  " " .. .   -*@*@-BYBY!.!9!9=;W;WY Wm&>&>?r7pluginsc` tj||d\}}|j xr |j }|js%|s#d}tj|dd|d|_tj||stjd|jr t|}n*tj|rtjd|j rB|j r6t!|t#||\}}t%|d| }t'|||ntjd tj|r8tj(||j} tj*| |||y#tj$r}t |cYd}~Sd}~wwxYw) 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?Fallow_multiple custom_promptrVOne ore more of the requested enhancements are not supported by the selected installerzLOne or more of the requested enhancements require --cert-name to be providedrrzPath 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_selchoose_configurator_pluginsrPluginSelectionErrorrrrr:r get_certnamesr' are_supportedNotSupportedError_populate_from_certname are_requestedr_check_certificate_and_keyrr%rYrenable) r(rZr_r  custom_certcertname_questionr9r8r;s r5r\r\'s$;;FGYW 1??7v'7'7K ??;J&44 Ie+--.0  % %fi 8&&(UV V (0  # #F +'')MN N6++"6*.vyA #F$)T fi1'')EF F!!&)33FFOOLGWi@ M  & &1v sFF- F("F-(F-c6tj||j}|s|S|js|j|_|js|j|_|j s|j |_|j s|j |_|S)zfHelper function for install to populate missing config values from lineage defined by --cert-name.)rrr:rrrr)r(r;s r5rhrhds//HG  ??!**   ",,   #..  ' 6 6 Mr7ctjjtj|j s.t jdj|j tjjtj|js.t jdj|jy)Nz-Error while reading certificate from path {0}z-Error while reading private key from path {0}) r%pathisfiler#realpathrrrrDrr4s r5rjrjvs 77>>*--f.>.>? @'')..4fV5E5E.FH H 77>>*--foo> ?'')..4fV__.EG G @r7ctjd|j|jgn |j}|jj|}tjd|t j t jd}|js|js|t|y|j|tjd||js|t|y|j|j}tjd||t|y)zList 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) rrifacesvisible functoolspartialr2r3initpreparer available)r(rZrufilteredrCr{s r5 plugins_cmdr}s LL*FMM:==(RfmmF ''/H LL'2   |88 FF ;;v~~s8} MM& LL'2 >>s8} ""$I LL'3 3y>r7cJgd}tfd|D}tjs=|s;d}tj |t j tjd tj|d\}}tj|stjdd}tj dd | d _tj$j"} | tj&d j(r| } n/d } t+j,| | } | stj&dtj.j"} | stj&dj0s| j0_|r,t3d|} | j5| j0d tjrtj6| | |y#tj$r}t|cYd}~Sd}~wwxYw)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 )hstsredirectuirstaplec36K|]}t|ywr )getattr).0enhr(s r5 zenhance..sNwvs+Nsz|Please specify one or more enhancement types to configure. To list the available enhancement types, run: %s --help enhance z#No enhancements requested, exiting.enhanceNr`zFWhich certificate would you like to use to enhance your configuration?Fr]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.ra)redirect_default)anyr'rirerrorrrtrMisconfigurationErrorrbrcrdrrfrgrrer:rrJnoninteractive_moder choose_valuesrrr%rWrk)r(rZsupported_enhancements oldstyle_enhrrrlr rn cert_domainsr9domain_questionr;r8s` r5rrsCN7MNNL  % %f -lN S#//***+PQQ;;FGYW 1  % %fi 8&&(UV V/"00 %'))*,FO 44VV__MLll_`` !!8++L/J,, 34 4//HG llWXX   #..#F$)T   &*;*;e T!!&)GWi@ I  & &1v s-G::H" HH"H"c\tj|j|j||y)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)rrollbackr checkpoints)r(rZs r5rrs" OOF$$f&8&8&'Jr7cbtjdttj|y)aUpdate 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 z1update_symlinks is deprecated and will be removedN)warningswarnPendingDeprecationWarningrupdate_live_symlinksr(r&s r5update_symlinksrs"" MMEG`a%%f-r7c.tj|y)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)rrename_lineagers r5renamer s"'r7c.tj|y)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)rrrs r5rrs"r7c.tj|y)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 certificatesrs r5rr2sf%r7cdx|_|_|j|jrtt j t j ||j|}|j|_|jr\|jdsK|j|_n9|jr|jr!|jrtjd|jtjd|j|jtj|j|jt!|jd5}t"j$j'|j)}dddt+j,|}nYtjd|jt/|\}}t+j,||j0|j2}t!|jd5}tj4|j)d}dddtjd|j6 |j9t#j:|j6t=|tEjF|jy#1swY:xYw#1swYxYw#t>j@$r} tC| cYd} ~ Sd} ~ wwxYw) 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 %srbzRevoking %s using Account KeyrzReason code for revocation: %s)$rrrr:r RenewableCertrr,r\rrJrrrrverify_cert_matches_priv_keyopenjoseJWKrreadracme_from_config_keyrrLr.pyopenssl_load_certificatereasonrevokeComparableX509r! acme_errors ClientErrorrrsuccess_revocation) r(r&r;frLrrrlrRr s r5rrCs//32Fv+ FOO''  - -ffoo FP",, >>&"4"4X">#NNFM   &"2"2vll`aa " ;%%v 8001A1A6??S &//4 ( *A((--)C ***637 4f6F6FG#F+Q**6377CHHE f %C55affh?BC LL16==A D''-v}}=v&""6#3#34 % * *CC  " "1v s6 .J1'J>:K 1J;>K K2 K-'K2-K2c8 tj||d\}}|j r7|r5d|j vr#tjd|jdtj||stjdt|||}t||\}}t|||\}} | } |rt||||| } | r | jnd} | r | j nd} | r | j"nd} |rt%|| | | d} t'|||| tj(|r| rtj*| |||| |st-j.|nt-j0|t5||| ||r|t7|t9j:||j<y#tj$r}t |cYd}~Sd}~wwxYw#tj2$r }|}Yd}~d}~wwxYw#t5||| ||r|wxYw)zObtain 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}Nz staple-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.r`r)rbrcrrdr must_staplerrgrr'rfr%rrrQrrrrrYrirkrsuccess_installationsuccess_renewalrJrr6rhandle_subscriptionr)r(rZrrr r8r9r:should_get_certr; new_lineagerrrrs r5r}r}zs0 #+#G#GPWY^#_ =iMAaAaAc,c&&  **+,a a    % %fi 8&&(UV V  yAI1&)DGX)&'8DOWK(FG g *5 %%$I3>[//DN'2{##HNHE-1M fi+>  % %f -+    Wi H ?/  , ,W 5  ' ' 0 6=+/> @  $V,FI$5$56 A  & &1v j <<  6=+/> @   sHF7 A,G"7G GGG"H5G<7H<HHHc |j\}}tj|j}t j dj |jrdndtj||j|\}}|jr!tjd|jy|j||tj j#|jtj j#|j$tj j#|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@rAr>z*Dry run: skipping saving certificate to %sNNN) actual_csrrget_names_from_reqdatar2rCrDrErFrGobtain_certificate_from_csrrrrsave_certificater%rqnormpathrr) r(r8rrl csr_namesrRchainrrrs r5_csr_get_and_save_certrs (  FC..sxx8I ''9?5.)?? J ( 77S>S-T-V)Iz> j. 00r7cPtj||d\}}t|||}t|||}|st j d|rX|j sKtj|||tjd|jd|jyyy)aRenew & 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) rbrcr%rQrrJrErrun_renewal_deployerr2rCrrestart)r(rZr;rauthr8renewed_lineages r5rIrIs(::67JWOIti8I(FGLO ll[\\$$V_iHj)9)9(::[\] (yr7ctj||d\}}t|||}|jrdt ||\}}}t ||||t |dd|j t|tj||jyt||\}} t||| \} } | stjddyt!|||| | } d} | r?|r=|js1t"j%d|j& |j)| r | j.nd}| r | j0nd}| r | j2nd}t5||||t || | | xr |j | r| t|tj||jy#t*j,$r } | } Yd} ~ d} ~ wwxYw)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~Nrz5Certificate not yet due for renewal; no action taken.Fr,z.Reloading %s server after certificate issuance)rbrcr%rrrrrEr6rrrrrr2r3rQrrrrrrJrrrr)r(rZrrr8rrrr9r:rr;rr rs r5r~r~s&::67JWOIti8I zz0Fvy0Y- :~VY NK64v~~CUV(0  (9(9:1&)DGX)&'8DOW !!"Y+0 2 FGXwOG-1M9V^^ DfFVFVW     &-!!$I/6W++DN#*wHVYAv}g+:+Q6>>?QS$V,FI$5$56|| M sF//GG  Gcg}g} tj|\}}tj||y#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)rhandle_renewal_requestrrun_saved_post_hooks)r(r&rPfailed_domainss r5r+r+XsJ"$O "ND*1*H*H*P' ""?NC""?NCs 5A ctj|jtj|j t jd5tj|jtj|j ddd|j|j|jf}|D]#}tj||j %y#1swYUxYw)zCreate or verify existence of config, work, and hook directories. :param config: Configuration object :type config: configuration.NamespaceConfig :returns: `None` :rtype: None N)strict) rset_up_core_dir config_dirrCONFIG_DIRS_MODEstrict_permissionsr# temp_umaskwork_dirrenewal_pre_hooks_dirrenewal_deploy_hooks_dirrenewal_post_hooks_dirmake_or_verify_dir)r( hook_dirshook_dirs r5make_or_verify_needed_dirsros **I,F,FHaHab   u %e V__i.H.H&JcJcde--00..1IL 1J1JKL ees :CC& renewal_fileorig_renewal_confc tj|dd}|d}|d}||k(rd}nd}t j |y#tj$rtjd|wxYw)a@Reports the outcome of certificate renewal reconfiguration to the user. :param renewal_file: Path to the cert's renewal file :type renewal_file: str :param orig_renewal_conf: Loaded original renewal configuration :type orig_renewal_conf: configobj.ConfigObj :returns: `None` :rtype: None rrerror parsing renewalparamsz3 No changes were made to the renewal configuration.zT Successfully updated configuration. Changes will apply when the certificate renews.N)rrConfigObjErrorrCertStorageErrorr2rC)rrfinal_renewal_conforig_renewal_paramsfinal_renewal_paramssuccess_messages r5_report_reconfigure_resultsrs-&00 7WF ,O<-o>22PN(  # #-%%\N +- --s A,A0c <|jrtjd|js#d}t j |dd|d|_|j} t j||}|jr,|js d }tj|d d d |_ tj|d d }t!j"|} t%j&||}|stjd|d} |j+dr(|j,| dk(r|j. | d|_dD]7} t1|| | j3| k7s"d}tj|t5j6||d\} } t!j"|}d|_d|_t=j>d|tA|| | }tC|||||jE|tG||y#tj$rtjd|dwxYw#tj$rtjd|wxYw#t($r$} tjd|d|d| dd} ~ wwxYw)a4Allow the user to set new configuration options for an existing certificate without forcing renewal. This can be used for things like authenticator, installer, and hooks, but not for the domains on the cert, since those are only saved in the cert. :param config: Configuration object :type config: configuration.NamespaceConfig :param plugins: List of plugins :type plugins: plugins_disco.PluginsRegistry :raises errors.Error: if the dry run fails :raises errors.ConfigurationError: if certificate could not be loaded akYou have specified domains, but this function cannot be used to modify the domains in a certificate. If you would like to do so, follow the instructions at https://certbot.org/change-cert-domain. Otherwise, remove the domains from the command to continue reconfiguring. You can specify which certificate you want on the command line with flag --cert-name instead.z0Which certificate would you like to reconfigure? reconfigureFr]rz"An existing certificate with name zO could not be found. Run `certbot certificates` to list available certificates.aaYou are attempting to set a --deploy-hook. Would you like Certbot to run deploy hooks when it performs a dry run with the new settings? This will run all relevant deploy hooks, including directory hooks, unless --no-directory-hooks is set. This will use the current active certificate, and not the temporary test certificate acquired during the dry run.zRun deploy hookszDo not run deploy hooksrrrrzRenewal configuration file z (cert: z ) produced an unexpected error: r(Nz0Could not load certificate. See logs for errors.rr,r)rr,a.Using reconfigure to change the ACME account or server is not supported. If you would like to do so, use renew with the --force-renewal flag instead of reconfigure. Note that doing so will count against any rate limits. For more information on this method, see https://certbot.org/renew-reconfigurationr~T)r:r;)$r9rrr:rrerrrrLrun_deploy_hooksr2r]rrrcopydeepcopyr reconstituterr\r,rrgetrbrcrrErset_test_server_optionsr%rQsave_new_config_valuesr)r(rZrnr:rrrlineage_configrenewal_candidater rparamrrdry_run_lineage_configr8s r5rrs"~~'')JK K ??N&44 M%+--.0HT88J &"9"9: #/"4"4S9K %u#6-%// 7WF ]]6*NF#00N ''(Z[[%o6M!!(+0E0EW_I`0`  " " *!.y!9'1 >5 )]->->u-E E?C ++C0 01::>7T^_OIt"]]>: 26.%)" /EF 6iHI y"88!# ,,^< .?@O  " "T''*LXJWS)ST TT$  # #-%%\N +- -- F''*El^TZ?s!)EF FFs0H-H?I.-H<?,I+. J7JJc#Kd}d}|jr7d|_ttjd}t j |}n^|jr$t j tj}n.t jtj|j} ||r|jyy#|r|jwwxYww)zCreates a display object appropriate to the flags in the supplied config. :param config: Configuration object :returns: Display object NTw) r0rrr%devnull display_objNoninteractiveDisplayrur FileDisplayrYclose)r( displayerrs r5make_displayerrs15 G ||%)"rzz3'55g>  # #55cjjA ++ JJ002   MMO 7 MMO sB&C)C-CCCcli_argsc|stjdd}tjtj j ddk(rtj|}tjj}tjdtjtjdtjdtjd|tjd |t!j"t%j&||}t!j( tj*|t-|t7|5}t9j:||j3||cdddS#t.j0$r|j2t4k7rYewxYw#1swYyxYw) zRun 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` rmNCERTBOT_SNAPPEDTruezcertbot version: %sz#Location of certbot entry point: %srz Arguments: %rzDiscovered plugins: %r)rurvrpre_arg_parse_setupr%environrr prepare_env plugins_discoPluginsRegistryrrrcertbot __version__r$prepare_virtual_consolerprepare_and_parse_args+raise_for_non_administrative_windows_rightspost_arg_parse_setuprrrJfuncr}rr set_display)rrZr(rs r5mainr8s[ 88AB< zz~~'(F2**84++446G LL&(;(;< LL6 D LL(+ LL)73   " ' ' :F 446   ("6*  ,9 *{{67+,, << ;;+ %  & ,,s5 F 'F>'F;:F;>Grr )T)__doc__ contextlibrrrwlogging.handlersloggingrutypingrrrrrr r r r rrjosepyrr rr acme_clientrrrrr rrrrcertbot._internalrrrrrrrrrrrcertbot._internal.displayr rrFcertbot._internal.pluginsr!r r"rbcertbot.compatr#r$r%certbot.displayr&rr2certbot.pluginsr'rw getLogger__name__rNamespaceConfigr6r$rrrQboolrcrzrrrrrrrr InstallerrrJrrrrAccountClientV2rr! Authenticatorr%r r3rrDrRrrYr\rhrjr}rrrrrrrr}rrIr~r+rrrrrrrintrr r7r5r+s &  &&*!%*!$'!#!%)%%8C<;%.0()   8 $]-J-Jt6W[BF?&--?9V9V? (c 3?FNsm? ()>)> ??%W%:%:;?D,-2O2O,070E0E,JN,^-' (E(E-')1#-'&-&;&;-'&+39N9N0O+O%P-'`2/=+H+H2/,3,A,A2/(-c8G)> ??@,2(T--(T8)> ?L,0L<@L`OS*]::*xPS}*%-c]*>Fsm*W[*Zm&C&C#!>!>#8TW=#%-c]#DLSM#VZ#LA}<<A!'//"*;+?+?"@#ABAH1 =#@#@1 T1 hKM99K#+J,D,D#EK' (<(<=KBH--K8(}44(,<<(AI#(V]22*::?G}>3=883#0#@#@3EMc]3l/66/#0#@#@/EMc]/d m.K.K /78M8M/N S[\_S`  RV@-77@FMM@9@/78M8M/N@Z^@::M11:"22:7?}:zM$A$AmFcFc$G}'D'DGG# 55#&66#;?#L=M11="22=7?}=@ K]22 K]=Z=Z K_c K .M99.$1$A$A.FJ.*(=00((88(=A(( =00 (88 =A (&66&!.!>!>&CG&"4=004(884=Ec]4nR --R..R3;C=Rj%1=#@#@%1&,mm%18=#C=(3-#F9H%1P }44 }?\?\ -- 26 F;7]22;7]=Z=Z;7_c;7|D-//D'77D<@D.L}'D'DLL.)c)iFYFY)^b)@oA 55oA 00oA59oAd=88!% (I(I(3(?(?)@#ABF#MN>.,8DI&.,(5c?2K.,r7