M/e.ddZddlZddlmZddlmZddlmZddlmZddlmZddlmZdd lm Z dd l m Z dd l m Z dd l mZdd l mZddl mZddl mZddlmZddlmZddlmZddlmZddlmZddlmZddlmZej>e Z!GddejDejFZ#y)zManual authenticator pluginN)Any)Callable)Dict)Iterable)List)Tuple)Type) challenges) achallenges)errors) interfaces)reverter)util)hooks) cli_constants)misc)os)ops)commonceZdZdZdZdZdZdZdZdZ dZ d Z d e d e d d ffd Z ededd d fdZd#dZd#dZd efdZdeej.d efdZded eeej6fdZdeej.d eej<fdZdej.deej.d d fdZ d$dej.de!d d fdZ"deej.d d fdZ#d ed!ed e$eeffd"Z%xZ&S)% AuthenticatorzManual authenticator This plugin allows the user to perform the domain validation challenge(s) themselves. This either be done manually by the user or through shell scripts provided to Certbot. z2Manual configuration or run your own shell scriptsTaAuthenticate through manual configuration or custom shell scripts. When using shell scripts, an authenticator script must be provided. The environment variables available to this script depend on the type of challenge. $CERTBOT_DOMAIN will always contain the domain being authenticated. For HTTP-01 and DNS-01, $CERTBOT_VALIDATION is the validation string, and $CERTBOT_TOKEN is the filename of the resource requested when performing an HTTP-01 challenge. An additional cleanup script can also be provided and can use the additional variable $CERTBOT_AUTH_OUTPUT which contains the stdout output from the auth script. For both authenticator and cleanup script, on HTTP-01 and DNS-01 challenges, $CERTBOT_REMAINING_CHALLENGES will be equal to the number of challenges that remain after the current one, and $CERTBOT_ALL_DOMAINS contains a comma-separated list of all domains that are challenged for the current certificate.zcPlease deploy a DNS TXT record under the name: {domain}. with the following value: {validation} a Before continuing, verify the TXT record has been deployed. Depending on the DNS provider, this may take some time, from a few seconds to multiple minutes. You can check if it has finished deploying with aid of online tools, such as the Google Admin Toolbox: https://toolbox.googleapps.com/apps/dig/#TXT/{domain}. Look for one or more bolded line(s) below the line ';ANSWER'. It should show the value(s) you've just added. zuCreate a file containing just this data: {validation} And make it available on your web server at this URL: {uri} z (This must be set up in addition to the previous challenges; do not remove, replace, or undo the previous challenge tasks yet.) z (This must be set up in addition to the previous challenges; do not remove, replace, or undo the previous challenge tasks yet. Note that you might be asked to create multiple distinct TXT records with the same name. This is permitted by DNS standards.) argskwargsreturnNct||i|tj|j|_|jj i|_d|_d|_y)NF) super__init__rReverterconfigrecovery_routineenvsubsequent_dns_challengesubsequent_any_challenge)selfrr __class__s B/usr/lib/python3/dist-packages/certbot/_internal/plugins/manual.pyrzAuthenticator.__init__asR $)&) ))$++6  &&(IK(-%(-%add).NcZ|dd|ddtj|ddy)N auth-hookz8Path or command to execute for the authentication script)help cleanup-hookz1Path or command to execute for the cleanup scriptzpublic-ip-logging-okr)radd_deprecated_argument)clsr(s r&add_parser_argumentsz"Authenticator.add_parser_argumentsis1 KK M ND F $$S*@!Dr'c|jjrD|jds3tjdj |j d|jy)Nr*zdAn authentication script must be provided with --{0} when using the manual plugin non-interactively.)rnoninteractive_modeconfr PluginErrorformat option_name_validate_hooksr$s r&preparezAuthenticator.prepareqsX ;; * *499[3I$$==CV$$[1>34 4 r'c|jjrPdD]J}|j|}||j|dt d }t j ||Lyy)N)r*r,z-hook)rvalidate_hooksr2r5lenr validate_hook)r$namehook hook_prefixs r&r6zAuthenticator._validate_hooksysc ;; % %5 ;yy#"&"2"24"83w<-"HK''k:  ; &r'c y)NzThis plugin allows the user to customize setup for domain validation challenges either through shell scripts provided by the user or by performing the setup manually.r7s r& more_infozAuthenticator.more_infos  < =r'failed_achallsc dttjdtffd }|tj}tjdtj dtj di}djt|jDcgc]\}}||s|c}}}|jdr+d jtj||rd Sd Sd j||rdSd Scc}}w)Nr.rc.tfdDS)Nc3JK|]}t|jywN) isinstancechall).0achallr.s r& z=Authenticator.auth_hint..has_chall..sRz&,,4Rs #)any)r.rCs`r& has_challz*Authenticator.auth_hint..has_challsR>RR Rr'zDNS TXT recordszchallenge fileszTLS-ALPN certificatesz and r*zThe Certificate Authority failed to verify the {resources} created by the --manual-auth-hook. Ensure that this hook is functioning correctly{dns_hint}. Refer to "{certbot} --help manual" and the Certbot User Guide.zD and that it waits a sufficient duration of time for DNS propagation)certbot resourcesdns_hintzThe Certificate Authority failed to verify the manually created {resources}. Ensure that you created these in the correct location{dns_hint}.z?, or try waiting longer for DNS propagation on the next attempt)rQrR)r r ChallengeboolDNS01HTTP01 TLSALPN01joinsorteditemsr2r4r cli_command)r$rCrNhas_dnsresource_nameskvrQs ` r& auth_hintzAuthenticator.auth_hints, S4 4 45 S$ SJ,,-   /   0  "9  LL~7K7K7M(^tq!QZ[\Q](^!_` 99[ !Q)55'!_  ')  S'"Z (*  !)_s D !D domaincBtjtjgSrG)r rVrU)r$ras r&get_chall_prefzAuthenticator.get_chall_prefs!!:#3#344r'achallscng}d}t|D],\}}t|jtjs+|}.t|D]h\}}|j dr|j ||n|j|||k(|j|j|jj|S)Nrr*) enumeraterHrIr rUr2_perform_achall_with_script_perform_achall_manuallyappendresponse account_key)r$rd responseslast_dns_achallirKs r&performzAuthenticator.performs "7+ $IAv&,, (8(89"# $#7+ BIAvyy%00A--fa?6JK   V__V-?-?@ A  B r'rKc X|j|j|jdjd|Dt t ||j |z dz d}t|jtjr|jjd|d<n tjjddtjj||j!d|j\}}|j#|d<||j$|<y) N,c34K|]}|jywrGra)rJ one_achalls r&rLz.s+X*J,=,=+Xs)CERTBOT_DOMAINCERTBOT_VALIDATIONCERTBOT_ALL_DOMAINSCERTBOT_REMAINING_CHALLENGEStoken CERTBOT_TOKENr*CERTBOT_AUTH_OUTPUT)ra validationrkrXstrr;indexrHrIr rVencoderenvironpopupdate _execute_hookstripr!)r$rKrdr!_outs r&rgz)Authenticator._perform_achall_with_scripts%mm"("3"3F4F4F"G#&88+XPW+X#X,/G w}}V?T0TWX0X,Y   fllJ$5$5 6#)<<#6#6w#?C JJNN?D 1 ###K?3%(YY[ !"r'rmc|j|j}t|jtj rq|j j||jjd|jj|jj|j|}n\t|jtjsJ|jj|j|j|}t|jtjry|j r||j"z }n|j$r||j&z }d|_|rT||j(j|j|jz }n|j$r||j&z }t+j,|ddd|_y)Nrz)rK encoded_tokenporturir})rar}TrsF)wrapforce_interactive)r}rkrHrIr rV_HTTP_INSTRUCTIONSr4rr http01_portrrarU_DNS_INSTRUCTIONSvalidation_domain_namer"&_SUBSEQUENT_DNS_CHALLENGE_INSTRUCTIONSr#"_SUBSEQUENT_CHALLENGE_INSTRUCTIONS_DNS_VERIFY_INSTRUCTIONS display_util notification)r$rKrmr}msgs r&rhz&Authenticator._perform_achall_manuallys&&v'9'9: fllJ$5$5 6))00V\\-@-@-I[[,,LL$$V]]3 1LC fllJ,<,<= ==((//44V]]C%0'C fllJ$4$4 5,,tBBB..t>>>,0D )t44;;!88G<II  * * 4:: :C!!#ETJ(,%r'c\|jdr|D]|}|jj|}d|vr tjjddtjj ||j d|j~|jjy)Nr,r{) r2r!rrrrrrarr )r$rdrKr!s r&cleanupzAuthenticator.cleanups 99^ $! Bhhll6*"#-JJNN?D9 !!#&"">6==A  B &&(r' hook_name achall_domainctj|j||j|t j \}}}t jd|d||||||fS)N)r!zHook '--manual-z' for )rexecute_command_statusr5r2renv_no_snap_for_external_calls display_opsreport_executed_command)r$rr returncodeerrrs r&rzAuthenticator._execute_hooksq#::   Y '9)=335  C ++i[}o > CQT VCxr')rN)F)'__name__ __module__ __qualname____doc__ descriptionhiddenlong_descriptionrrrrrrr classmethodrr/r8r6r~rBrr AnnotatedChallenger`r r rSrcrChallengeResponserorgrTrhrrr __classcell__)r%s@r&rrsGK F O* *&.*.c.S.T.Ex ':EtEE;=3= #1O1O(P#UX#J5S5Xd:;O;O6P-Q5 tK$B$BC *667 +2P2P-1+2P2P-QVZ$:?-{/M/M-26-CG-@)x (F(FG)D) s 3 5c? r'r)$rloggingtypingrrrrrrr acmer rPr r r rrcertbot._internalrcertbot._internal.clircertbot.compatrrcertbot.displayrrrcertbot.pluginsr getLoggerrloggerPluginrrAr'r&rss!#/.0"   8 $gFMM:#;#;gr'