????

Your IP : 18.220.124.7


Current Path : /usr/lib/python3.6/site-packages/certbot/_internal/plugins/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/certbot/_internal/plugins/__pycache__/manual.cpython-36.pyc

3

گa�.�@s dZddlZddlmZddlmZddlmZddlmZddlmZddlmZdd	lm	Z	dd
l
mZddlm
Z
ddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZeje �Z!Gdd�dej"ej#�Z#dS)zManual authenticator plugin�N)�Any)�Callable)�Dict)�Iterable)�List)�Tuple)�Type)�
challenges)�achallenges)�errors)�
interfaces)�reverter)�util)�hooks)�
cli_constants)�misc)�os)�ops)�commoncs8eZdZdZdZdZdZdZdZdZ	dZ
d	Zeed
d��fdd
�Z
eed.d
d�dd��Zd
d�dd�Zd
d�dd�Zed�dd�Zeejed�dd�Zeeeejd�dd�Zeejeejd�d d!�Zejeejd
d"�d#d$�Z d/eje!d
d&�d'd(�Z"eejd
d�d)d*�Z#eee$eefd+�d,d-�Z%�Z&S)0�
Authenticatorz�Manual 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 scriptsTa�Authenticate 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.)
N)�args�kwargs�returncs<t�j||�tj|j�|_|jj�i|_d|_d|_dS)NF)	�super�__init__r
ZReverter�config�recovery_routine�env�subsequent_dns_challenge�subsequent_any_challenge)�selfrr)�	__class__��/usr/lib/python3.6/manual.pyras
zAuthenticator.__init__.)�addrcCs*|ddd�|ddd�tj|dd�dS)Nz	auth-hookz8Path or command to execute for the authentication script)�helpzcleanup-hookz1Path or command to execute for the cleanup scriptzpublic-ip-logging-okr)rZadd_deprecated_argument)�clsr$r"r"r#�add_parser_argumentsis
z"Authenticator.add_parser_arguments)rcCs6|jjr*|jd�r*tjdj|jd����|j�dS)Nz	auth-hookzdAn authentication script must be provided with --{0} when using the manual plugin non-interactively.)rZnoninteractive_mode�confrZPluginError�format�option_name�_validate_hooks)r r"r"r#�prepareqs
zAuthenticator.preparecCsP|jjrLxBdD]:}|j|�}|dk	r|j|�dtd��}tj||�qWdS)N�	auth-hook�cleanup-hookz-hook)r-r.)rZvalidate_hooksr(r*�lenrZ
validate_hook)r �name�hookZhook_prefixr"r"r#r+ys

zAuthenticator._validate_hookscCsdS)Nz�This 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.r")r r"r"r#�	more_info�szAuthenticator.more_info)�failed_achallsrcs��fdd���tj�}tjdtjdtjdi}djt�fdd�|j�D���}|jd	�rpd
jt	j
||rhdndd
�Sdj||r~dndd�SdS)Ncst�fdd��D��S)Nc3s|]}t|j��VqdS)N)�
isinstance�chall)�.0�achall)r&r"r#�	<genexpr>�sz<Authenticator.auth_hint.<locals>.<lambda>.<locals>.<genexpr>)�any)r&)r3)r&r#�<lambda>�sz)Authenticator.auth_hint.<locals>.<lambda>zDNS TXT recordszchallenge fileszTLS-ALPN certificatesz and csg|]\}}�|�r|�qSr"r")r6�k�v)�	has_challr"r#�
<listcomp>�sz+Authenticator.auth_hint.<locals>.<listcomp>z	auth-hookz�The 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�	resources�dns_hintz�The 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)rArB)r	�DNS01�HTTP01Z	TLSALPN01�join�sorted�itemsr(r)rZcli_command)r r3Zhas_dnsZresource_namesrAr")r3r=r#�	auth_hint�s

 
zAuthenticator.auth_hint)�domainrcCstjtjgS)N)r	rDrC)r rIr"r"r#�get_chall_pref�szAuthenticator.get_chall_pref)�achallsrcCs�g}d}x&t|�D]\}}t|jtj�r|}qWxNt|�D]B\}}|jd�rZ|j||�n|j|||k�|j|j	|j
��q:W|S)Nrz	auth-hook)�	enumerater4r5r	rCr(�_perform_achall_with_script�_perform_achall_manually�appendZresponse�account_key)r rKZ	responses�last_dns_achall�ir7r"r"r#�perform�s
zAuthenticator.perform)r7rKrcCs�t|j|j|j�djdd�|D��tt|�|j|�d�d�}t|j	t
j�r`|j	jd�|d<nt
jjdd�t
jj|�|jd|j�\}}|j�|d	<||j|<dS)
N�,css|]}|jVqdS)N)rI)r6Z
one_achallr"r"r#r8�sz<Authenticator._perform_achall_with_script.<locals>.<genexpr>�)ZCERTBOT_DOMAINZCERTBOT_VALIDATIONZCERTBOT_ALL_DOMAINSZCERTBOT_REMAINING_CHALLENGES�token�
CERTBOT_TOKENz	auth-hookZCERTBOT_AUTH_OUTPUT)�dictrI�
validationrPrE�strr/�indexr4r5r	rD�encoder�environ�pop�update�
_execute_hook�stripr)r r7rKr�_�outr"r"r#rM�s
z)Authenticator._perform_achall_with_scriptF)r7rQrcCs�|j|j�}t|jtj�rH|jj||jjd�|j	j
|jj|j�|d�}n*t|jtj
�sZt�|jj|j|j�|d�}t|jtj
�r�|jr�||j7}n|jr�||j7}d|_|r�||jj|j|j�d�7}n|jr�||j7}tj|ddd�d|_dS)NrV)r7Z
encoded_tokenZport�urirY)rIrYT)rIF)ZwrapZforce_interactive)rYrPr4r5r	rD�_HTTP_INSTRUCTIONSr)r\rZhttp01_portrdrIrC�AssertionError�_DNS_INSTRUCTIONSZvalidation_domain_namer�&_SUBSEQUENT_DNS_CHALLENGE_INSTRUCTIONSr�"_SUBSEQUENT_CHALLENGE_INSTRUCTIONS�_DNS_VERIFY_INSTRUCTIONS�display_utilZnotification)r r7rQrY�msgr"r"r#rN�s.


z&Authenticator._perform_achall_manuallycCsb|jd�rTxH|D]@}|jj|�}d|kr6tjjdd�tjj|�|jd|j�qW|jj	�dS)Nzcleanup-hookrW)
r(rr^rr]r_r`rIr
r)r rKr7rr"r"r#�cleanup�s

zAuthenticator.cleanup)�	hook_name�
achall_domainrcCsJtj|j|�|j|�tj�d�\}}}tjd|�d|��|||�||fS)N)rzHook '--manual-z' for )rZexecute_command_statusr*r(rZenv_no_snap_for_external_calls�display_opsZreport_executed_command)r rnro�
returncode�errrcr"r"r#r`�szAuthenticator._execute_hook).N)F)'�__name__�
__module__�__qualname__�__doc__�descriptionZhiddenZlong_descriptionrgrjrerirhrr�classmethodrr'r,r+rZr2rr
ZAnnotatedChallengerHrr	Z	ChallengerJrZChallengeResponserSrM�boolrNrmrr`�
__classcell__r"r")r!r#rs0	$
r)$rvZloggingZtypingrrrrrrrZacmer	r@r
rrr
rZcertbot._internalrZcertbot._internal.clirZcertbot.compatrrZcertbot.displayrrprkZcertbot.pluginsrZ	getLoggerrsZloggerZPluginrr"r"r"r#�<module>s.