Edit File: auth_handler.cpython-36.opt-1.pyc
3 گa�O � @ s� d Z ddlZddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddlm Z ddlm Z ddlZdd lm Z dd lmZ ddlmZ ddlmZ dd lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z! ej"e#�Z$G dd� d�Z%ej&ej'e(ej)d�dd�Z*eej& ee ej+ e ee, df ee, d�dd�Z-eej& ee ej+ e ee, df ee, d�dd�Z.eej& ee ej+ ee, d �d!d"�Z/eej& ej0d#�d$d%�Z1eej) e(d&�d'd(�Z2dS ))zACME AuthHandler.� N)�Dict)�Iterable)�List)�Optional)�Tuple)�Type)�Response)� challenges)�client)�errors)�messages)�achallenges)� configuration)� interfaces)� error_handler)�Account)�util)�commonc @ s e Zd ZdZejeej ee e e dd�dd�Zd e jejeee e j d�d d �Ze jee e f d�dd �Ze e j eedd�dd�Zee j e ej d�dd�Zee eej d�dd�Ze ej dd�dd�Z e je e e ej d�dd�Z!e e j dd�dd�Z"dS )!�AuthHandlera ACME Authorization Handler for a client. :ivar auth: Authenticator capable of solving :class:`~acme.challenges.Challenge` types :type auth: certbot.interfaces.Authenticator :ivar acme.client.BackwardsCompatibleClientV2 acme_client: ACME client API. :ivar account: Client's Account :type account: :class:`certbot._internal.account.Account` :ivar list pref_challs: sorted user specified preferred challenges type strings with the most preferred challenge listed first N)�auth�acme_client�account�pref_challs�returnc C s || _ || _|| _|| _d S )N)r �acmer r )�selfr r r r � r �"/usr/lib/python3.6/auth_handler.py�__init__/ s zAuthHandler.__init__F� )�orderr�config�best_effort�max_retriesr c C s& |j dd� }|stjd��| js,tjd��| j|�}|s>|S tj| j|��� y$| j j |�}|jrptj ddd� W n< tjk r� } ztjd� tjd� |�W Y dd}~X nX x&t||�D ]\} } | jj| j| � q�W tjd � | j|||� d d� |D �}|�stjd��|S Q R X tjd ��dS )a� Retrieve all authorizations, perform all challenges required to validate these authorizations, then poll and wait for the authorization to be checked. :param acme.messages.OrderResource orderr: must have authorizations filled in :param certbot.configuration.NamespaceConfig config: current Certbot configuration :param bool best_effort: if True, not all authorizations need to be validated (eg. renew) :param int max_retries: maximum number of retries to poll authorizations :returns: list of all validated authorizations :rtype: List :raises .AuthorizationError: If unable to retrieve all authorizations NzNo authorization to handle.z9No ACME client defined, authorizations cannot be handled.z\Challenges loaded. Press continue to submit to CA. Pass "-v" for more info about challenges.T)�pausez!Failure in setting up challenges.z0Attempting to clean up outstanding challenges...zWaiting for verification...c S s g | ]}|j jtjkr|�qS r )�body�statusr �STATUS_VALID)�.0�authzrr r r � <listcomp>l s z5AuthHandler.handle_authorizations.<locals>.<listcomp>zAll challenges have failed.z?An unexpected error occurred while handling the authorizations.)�authorizationsr �AuthorizationErrorr �Error�_choose_challengesr ZExitHandler�_cleanup_challengesr ZperformZdebug_challenges�display_utilZnotification�logger�critical�info�zipZanswer_challenge�challb�_poll_authorizations)r r r! r"