
    M/eFe                        U d Z ddlZddlZddlZddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
Z
ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddlm!Z! ddlm"Z" ddlm#Z# ddlm$Z$ ddlm%Z% ddlm&Z& ddlm'Z' dd lm(Z( dd!lm)Z) dd"l*m+Z+ dd#l,m-Z- dd$l.m/Z/ dd%l0m1Z1 dd&l2m3Z3 dd'l4m5Z5 dd(l4m6Z6 dd)l7m8Z9 ddl:m;c m<c m=Z> dd*l?m@Z@  ej                  eB      ZCdaDee-   eEd+<   d,e9j                  d-eeG   d.efd/ZHd0ed.e	fd1ZIy)2z2Certbot command line argument & config processing.    N)Any)List)Optional)Type)NamespaceConfig)	constants)ARGPARSE_PARAMS_TO_REMOVE)cli_command)COMMAND_OVERVIEW)DEPRECATED_OPTIONS)EXIT_ACTIONS)HELP_AND_VERSION_USAGE)SHORT_USAGE)VAR_MODIFIERS)ZERO_ARG_ACTIONS)_DeployHookAction)_DomainsAction)_EncodeReasonAction)_PrefChallAction)_RenewHookAction)_user_agent_comment_type)add_domains)CaseInsensitiveList)config_help)CustomHelpFormatter)flag_default)HelpfulArgumentGroup)nonnegative_int)parse_preferred_challenges)	read_file)set_test_server_options)_add_all_groups)HelpfulArgumentParser)_paths_parser)_plugins_parsing)_create_subparsers)	VERB_HELP)VERB_HELP_MAP)disco)enhancementshelpful_parserpluginsargsreturnc                    t        ||       }t        |       |j                  dddddt        d      d       |j                  ddd	t        d	      t        j
                  
       |j                  dddddt        d      t        j
                         |j                  ddt        t        d      d       |j                  ddddt        d      t        j
                         |j                  g ddddddt        d      d       |j                  g dt        j                  dt        d      d       |j                  g dd d!d"d#d$t        t        d#      d%&	       |j                  g d'd(d)d*d+,       |j                  g d'd-d.d/d0,       |j                  g d1d2d3d4t        d3      d56       |j                  g d7d8dd9t        d9      d:;       |j                  g d<d=dd>t        d>      d?;       |j                  d@dAgdBdt        dC      dD       |j                  g dEdFdGt        dH      t        dH      I       |j                  g dJdKdt        dL      dLdMN       |j                  g dJdOdPt        dL      dLdQN       |j                  g dRdSdTdUdVdt        dV      dW       |j                  dAdXdt        dY      dZ       |j                  dAd[d\d]j                  t        j                        d^_       |j                  dAd`gdadbdcdt        dc      dd       |j                  dAdedfdt        df      dg       |j                  dAdhdidt        di      dj       |j                  dAdkdidPt        di      dl       |j                  dAdmdndt        dn      do       |j                  g dpdqdt        dr      ds       |j                  dAdtdudt        du      dv       |j                  dwdAgdxdyt        dz      d{|       |j                  dAd}d~dt        d~      d       |j                  g dddddt        d      d       |j                  g dddddt        d      dt        j                  z          |j                  dddt        d      d       |j                  g dddt        d      d       |j                  dddt        d      t        d             |j                  g ddt        dt        d      t        d             |j                  ddgddt        d      t        d      
       |j                  ddgdt        t        d      t        d             |j                  dddt        d      d       |j                  ddt        dt        d      t        d             |j                  ddddgt         t        d      t        d             |j                  ddt         g ddt        d      t        d             |j                  ddddt        d      t        d      ;       |j                  ddgdddt        d      d;       |j                  dddPdt        d      d;       |j                  ddgdddt        d      d;       |j                  dddPdt        d      t        j
                  ;       |j                  ddgdddt        d      d;       |j                  dddPdt        d      t        j
                  ;       |j                  ddddt        d      d¬;       |j                  dddPdt        d      t        j
                  ;       |j                  dddt        dū      dƬ       |j                  g dǢddt        dɫ      t        dɫ      
       |j                  g dʢddt"        t        d̫      dͬ       |j                  g ddt        dt        dϫ      t        dϫ             |j                  d`dgddҬӫ       |j                  d`dgddլӫ       |j                  d`dgdt$        t        j
                  ׫       |j                  d`ddPt        d٫      dt        j
                  N       |j                  d`dgdt&        d۬׫       |j                  d`ddPdt        dݫ      dެ;       |j                  d`ddPt        d      ddN       |j                  d`ddt        d      ddN       |j                  d`ddPt        d      ddN       |j)                  dd       |j)                  dd       |j)                  dd       |j)                  dd       t+        j,                  |j                         t/        |       t1        |       t3        ||        |a|j7                         S )a  Returns parsed command line arguments.

    :param .PluginsRegistry plugins: available plugins
    :param list args: command line arguments with the program name removed

    :returns: parsed command line arguments
    :rtype: configuration.NamespaceConfig

    Nz-vz	--verboseverbose_countcountzbThis flag can be used multiple times to incrementally increase the verbosity of output, e.g. -vvv.)destactiondefaulthelpz--verbose-levelverbose_level)r2   r4   r5   z-tz--text	text_mode
store_truez--max-log-backupsmax_log_backupszSpecifies the maximum number of backup logs that should be kept by Certbot's built in log rotation. Setting this flag to 0 disables log rotation entirely, causing Certbot to always append to the same log file.)typer4   r5   z--preconfigured-renewalpreconfigured_renewal)N
automationruncertonlyenhancez-nz--non-interactivez--noninteractivenoninteractive_modezRun without ever asking for user input. This may require additional command line flags; the client will try to explain which ones are required if it finds one missing)Nregisterr=   r>   r?   force_interactivezForce Certbot to be interactive even if it detects it's not being run in a terminal. This flag cannot be used with the renew subcommand.)r3   r4   r5   )Nr=   r>   certificatesr?   z-dz	--domainsz--domaindomainsDOMAINa  Domain names to include. For multiple domains you can use multiple -d flags or enter a comma separated list of domains as a parameter. All domains will be included as Subject Alternative Names on the certificate. The first domain will be used as the certificate name, unless otherwise specified or if you already have a certificate with the same name. In the case of a name conflict, a number like -0001 will be appended to the certificate name. (default: Ask))r2   metavarr3   r4   r5   )Nr=   r>   rA   z	--eab-kideab_kidEAB_KIDz+Key Identifier for External Account Binding)r2   rF   r5   z--eab-hmac-keyeab_hmac_keyEAB_HMAC_KEYz%HMAC key for External Account Binding)	Nr=   r>   managedeleterC   renewr?   reconfigurez--cert-namecertnameCERTNAMEa  Certificate name to apply. This name is used by Certbot for housekeeping and in file paths; it doesn't affect the content of the certificate itself. Certificate name cannot contain filepath separators (i.e. '/' or '\', depending on the platform). To see certificate names, run 'certbot certificates'. When creating a new certificate, specifies the new certificate's name. (default: the first provided domain or the name of an existing certificate on your system for the same domains))r2   rF   r4   r5   )NtestingrM   r>   z	--dry-rundry_runa  Perform a test run against the Let's Encrypt staging server, obtaining test (invalid) certificates but not saving them to disk. This can only be used with the 'certonly' and 'renew' subcommands. It may trigger webserver reloads to  temporarily modify & roll back configuration files. --pre-hook and --post-hook commands run by default. --deploy-hook commands do not run, unless enabled by --run-deploy-hooks. The test server may be overridden with --server.)r3   r2   r4   r5   )rQ   rM   r>   rN   z--run-deploy-hooksrun_deploy_hooksa  When performing a test run using `--dry-run` or `reconfigure`, run any applicable deploy hooks. This includes hooks set on the command line, saved in the certificate's renewal configuration file, or present in the renewal-hooks directory. To exclude directory hooks, use --no-directory-hooks. The hook(s) will only be run if the dry run succeeds, and will use the current active certificate, not the temporary test certificate acquired during the dry run. This flag is recommended when modifying the deploy hook using `reconfigure`.rA   r<   z!--register-unsafely-without-emailregister_unsafely_without_emaila"  Specifying this flag enables registering an account with no email address. This is strongly discouraged, because you will be unable to receive notice about impending expiration or revocation of your certificates or problems with your Certbot installation that will lead to failure to renew.)rA   update_account
unregisterr<   z-mz--emailemail)r4   r5   )rA   rU   r<   z--eff-email	eff_emailz"Share your e-mail address with EFF)r3   r4   r2   r5   z--no-eff-emailstore_falsez(Don't share your e-mail address with EFF)r<   r>   r=   z--keep-until-expiringz--keepz--reinstall	reinstallzIf the requested certificate matches an existing certificate, always keep the existing one until it is due for renewal (for the 'run' subcommand this means reinstall the existing certificate). (default: Ask)z--expandexpandzIf an existing certificate is a strict subset of the requested names, always expand and replace it with the additional names. (default: Ask)z	--versionversionz%(prog)s {0}z&show program's version number and exit)r3   r\   r5   rM   z--force-renewalz--renew-by-defaultrenew_by_defaultzIf a certificate already exists for the requested domains, renew it now, regardless of whether it is near expiry. (Often --keep-until-expiring is more appropriate). Also implies --expand.z--renew-with-new-domainsrenew_with_new_domainszIf a certificate already exists for the requested certificate name but does not match the requested domains, renew it now, regardless of whether it is near expiry.z--reuse-key	reuse_keyzDWhen renewing, use the same private key as the existing certificate.z--no-reuse-keyzWhen renewing, do not use the same private key as the existing certificate. Not reusing private keys is the default behavior of Certbot. This option may be used to unset --reuse-key on an existing certificate.z	--new-keynew_keyzWhen renewing or replacing a certificate, generate a new private key, even if --reuse-key is set on the existing certificate. Combining --new-key and --reuse-key will result in the private key being replaced and then reused in future renewals.)r<   rM   r>   z--allow-subset-of-namesallow_subset_of_namesa8  When performing domain validation, do not consider it a failure if authorizations can not be obtained for a strict subset of the requested domains. This may be useful for allowing renewals for multiple domains to succeed even if some domains no longer point at this system. This option cannot be used with --csr.z--agree-tostosz5Agree to the ACME Subscriber Agreement (default: Ask)rV   z	--account
ACCOUNT_IDaccountzAccount ID to use)rF   r4   r5   z--duplicate	duplicatezdAllow making a certificate lineage that duplicates an existing one (both can be renewed in parallel))r<   rM   r>   r=   z-qz--quietquietz\Silence all output except errors. Useful for automation via cron. Implies --non-interactive.)rQ   revoker=   z--test-certz	--stagingstagingzmUse the Let's Encrypt staging server to obtain or revoke test (invalid) certificates; equivalent to --server rQ   z--debugdebugz!Show tracebacks in case of errors)Nr>   r=   z--debug-challengesdebug_challengeszAfter setting up challenges, wait for user input before submitting to CA. When used in combination with the `-v` option, the challenge URLs or FQDNs and their expected return values are shown.z--no-verify-sslno_verify_ssl)r3   r5   r4   )rQ   
standalonemanualz--http-01-porthttp01_port)r:   r2   r4   r5   rl   z--http-01-addresshttp01_addressnginxz--https-port
https_portz--break-my-certsbreak_my_certsz]Be willing to replace or renew valid certificates with invalid (testing/staging) certificatessecurityz--rsa-key-sizeNrsa_key_size)r:   rF   r4   r5   z
--key-typersaecdsakey_type)choicesr:   r4   r5   z--elliptic-curve)	secp256r1	secp384r1	secp521r1elliptic_curve)r:   ry   rF   r4   r5   z--must-staplemust_stapler?   z
--redirectredirectzAutomatically redirect all HTTP traffic to HTTPS for the newly authenticated vhost. (default: redirect enabled for install and run, disabled for enhance)z--no-redirectzDo not automatically redirect all HTTP traffic to HTTPS for the newly authenticated vhost. (default: redirect enabled for install and run, disabled for enhance)z--hstshstszAdd the Strict-Transport-Security header to every HTTP response. Forcing browser to always use SSL for the domain. Defends against SSL Stripping.z	--no-hstsz--uiruirzAdd the "Content-Security-Policy: upgrade-insecure-requests" header to every HTTP response. Forcing the browser to use https:// for every http:// resource.z--no-uirz--staple-ocspstaplezmEnables OCSP Stapling. A valid OCSP response is stapled to the certificate that the server offers during TLS.z--no-staple-ocspz--strict-permissionsstrict_permissionsz}Require that all configuration files are owned by the current user; only needed if your config is somewhere unsafe like /tmp/)Nr>   rM   r=   z--preferred-chainpreferred_chain)rm   rl   r>   rM   z--preferred-challengespref_challsa  A sorted, comma delimited list of the preferred challenge to use during authorization with the most preferred challenge listed first (Eg, "dns" or "http,dns"). Not all plugins support all challenges. See https://certbot.eff.org/docs/using.html#plugins for details. ACME Challenges are versioned, but if you pick "http" rather than "http-01", Certbot will select the latest version automatically.z--issuance-timeoutissuance_timeoutrN   z
--pre-hooku  Command to be run in a shell before obtaining any certificates. Unless --disable-hook-validation is used, the command’s first word must be the absolute pathname of an executable or one found via the PATH environment variable. Intended primarily for renewal, where it can be used to temporarily shut down a webserver that might conflict with the standalone plugin. This will only be called if a certificate is actually to be obtained/renewed. When renewing several certificates that have identical pre-hooks, only the first will be executed.)r5   z--post-hooku  Command to be run in a shell after attempting to obtain/renew certificates. Unless --disable-hook-validation is used, the command’s first word must be the absolute pathname of an executable or one found via the PATH environment variable. Can be used to deploy renewed certificates, or to restart any servers that were stopped by --pre-hook. This is only run if an attempt was made to obtain/renew a certificate. If multiple renewed certificates have identical post-hooks, only one will be run.z--renew-hook)r3   r5   z--no-random-sleep-on-renewrandom_sleep_on_renewz--deploy-hookuA  Command to be run in a shell once for each successfully issued certificate. Unless --disable-hook-validation is used, the command’s first word must be the absolute pathname of an executable or one found via the PATH environment variable. For this command, the shell variable $RENEWED_LINEAGE will point to the config live subdirectory (for example, "/etc/letsencrypt/live/example.com") containing the new certificates and keys; the shell variable $RENEWED_DOMAINS will contain a space-delimited list of renewed certificate domains (for example, "example.com www.example.com")z--disable-hook-validationvalidate_hooksa  Ordinarily the commands specified for --pre-hook/--post-hook/--deploy-hook will be checked for validity, to see if the programs being run are in the $PATH, so that mistakes can be caught early, even when the hooks aren't being run just yet. The validation is rather simplistic and fails if you use more advanced shell constructs, so you can use this switch to disable it. (default: False)z--no-directory-hooksdirectory_hooksz`Disable running executables found in Certbot's hook directories during renewal. (default: False)z--disable-renew-updatesdisable_renew_updatesa  Disable automatic updates to your server configuration that would otherwise be done by the selected installer plugin, and triggered when the user executes "certbot renew", regardless of if the certificate is renewed. This setting does not apply to important TLS configuration updates.z--no-autorenew	autorenewz6Disable auto renewal of certificates. (default: False)z--os-packages-onlyr   z--no-self-upgradez--no-bootstrapz--no-permissions-check)r#   r"   addr   argparseSUPPRESSr   r   FORCE_INTERACTIVE_FLAGr   r   formatcertbot__version__STAGING_URIintstrr   r   r   add_deprecated_argumentr*   populate_clir&   r$   r%   r+   
parse_args)r,   r-   helpfuls      @/usr/lib/python3/dist-packages/certbot/_internal/cli/__init__.pyprepare_and_parse_argsr   :   sx    $D'2GG KKdKog_- 5   KKo_-H4E4E  G KKdH;|[)0A0A  C KK!./>  ? KK'.E\2I%J  
 KK:!#5"<23@  A KK8((01!	  " KK<k:IY'\  
] KK-):	   KK-~4	   KK	,-:L$<@	  A KK.LyY'A	  
B KK7\8J/0D	  
E KK	\"$GP\>?@  A KKBD)W%!  # KK<mT`$[19  ; KK<>N$l;.Gk?  A KK)=|K7P_	  ` KKj|H?UV  W KKk)%%g&9&9:5  7 KK	w/6H\2D%E	   KK07O\2J%K8  9 KKm+\+%>  
 KK&[l;&?%  & KKk|\)5L/  0 KK+!,45F	  G KKm%U#D  F KK	|$k<Y'   " KKm+l[)1  2
 KK2iglW%+	  , KK,m[|\)5L57@7L7LM  N KK9\<;P0  2 KK!#7/0(  ) KK$\)_-  / KK+-=C]++m2L  N KK	L!#6-.[AQ5R  T KK	Gn3\*&  ( KK%l-..  /
 KK$3^,;~3N  P KKL5'*:Z({:/F  H KK&S ;
 -.[AQ5R  T KKOLL$?'  ) KK	Y\
Z(%	  & KKOM
Z(%  & KK	YFL<P/  0 KKKFV$8+<+<  > KK	Y5,u:M5  6 KKJ}5,W\J]    KKOLxX&>  ?
 KK&}8X&X->->  @ KK*<12O  P
 KK*"3./kBS6T  
 KK5 }m)D	   KK!#7o/0+,	  .
 KK	- ,A  
B KK	- -	   KK-(.'h.?.?  AKK-m45<S    KK	- /:K   KK,#3-.	   KK'./6G,  -
 KK*<45<S   KK!-[)E  G ##$8!<##$7;##$4a8##$<a@ gkk*w' Wg& N    variablec                     t         ?t         j                  D ],  }|j                  |j                  | k(  s |j                  c S  t        S )zFReturn our argparse type function for a config variable (default: str))r+   actionsr:   r2   r   )r   r3   s     r   argparse_typer     sE     !$,, 	#F{{&6;;(+B{{"	# Jr   )J__doc__r   logginglogging.handlerssystypingr   r   r   r   r   certbot.configurationr   certbot._internalr   #certbot._internal.cli.cli_constantsr	   r
   r   r   r   r   r   r   r   certbot._internal.cli.cli_utilsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   !certbot._internal.cli.group_adderr"   certbot._internal.cli.helpfulr#   "certbot._internal.cli.paths_parserr$   %certbot._internal.cli.plugins_parsingr%    certbot._internal.cli.subparsersr&   certbot._internal.cli.verb_helpr'   r(   certbot._internal.pluginsr)   plugins_disco#certbot._internal.plugins.selection	_internalr,   	selectionplugin_selectioncertbot.pluginsr*   	getLogger__name__loggerr+   __annotations__PluginsRegistryr   r   r    r   r   <module>r      s    8    
      1 ' I ; @ B < F ; = @ = : ? < < D 7 ? 7 ? 8 @ ; F 5 C = ? < B ? 5 9 < > > (			8	$ 37./ 6c M$A$A c c c  /c LC D r   