o
    >e                     @   sP  d dl mZmZmZmZ d dlZd dlmZ d dlm	Z	 d dl
mZmZ d dlmZ d dlmZ d dlmZ 	d,d	ee	 d
ee deee ef dedeee ef dedee fddZdejd
efddZejdddedejddddedejdddeddddejd d!ddedgZed"ejd#Zd$ed%efd&d'Zd(d) Zd*d+ ZdS )-    )IterableOptionalTypeVarUnionN)ValidationContext)	CLIConfig)loggerreadable_file)ConfigurationError)init_validation_context_kwargs)load_certs_from_pemder
cli_configvalidation_contexttrusttrust_replaceother_certsretroactive_revinfoallow_fetchingc           
   
   C   s  z|d urAt ||frtd| d u rtdz	| j|dd}W nT ty@ } zd| d}	tj|	|d t|	d }~ww |sE|rNt||||d}n)| d uruz| jdd}W n tyt } zd	}	tj|	|d t|	d }~ww i }|d ur||d
< n|d
d |rd|d< |W S  tjy     t	y } zd}	tj|	|d t|	d }~w t
y } zd}	tj|	|d t|	d }~ww )NzC--validation-context is incompatible with --trust and --other-certszNo config file specified.T)as_dictzAConfiguration problem. Are you sure that the validation context 'z0' is properly defined in the configuration file?)exc_info)r   r   r   r   z*Failed to load default validation context.r   r   z+I/O problem while reading validation configz:Generic processing problem while reading validation config)anyclickClickExceptionget_validation_contextr
   r   errorr   
setdefaultIOError	Exception)
r   r   r   r   r   r   r   resultemsg r!   S/var/www/html/humari/django-venv/lib/python3.10/site-packages/pyhanko/cli/_trust.pybuild_vc_kwargs   sr   	






r#   ctxc                 C   s    | j j}|d u r
d S |j|dS )N)name)objconfigget_signer_key_usages)r$   r   r   r!   r!   r"   _get_key_usage_settingsU   s   r)   )z--validation-contextz"use validation context from configF)helprequiredtype)z--trustz#list trust roots (multiple allowed)T)r*   r+   multipler,   )z--trust-replacez4listed trust roots supersede OS-provided trust store)r*   r+   r,   is_flagdefaultshow_default)z--other-certsz#other certs relevant for validationFC)boundfreturnc                 C   s   | j t | S N)paramsextendTRUST_OPTIONS)r3   r!   r!   r"   trust_options   s   r9   c                 C   s6   |r	|r	t d|rd}n|rd}nd}|| d< | S )Nz<--soft-revocation-check is incompatible with --force-revinforequirez	soft-failz	hard-failrevocation_mode)r   r   )	vc_kwargssoft_revocation_checkforce_revinforev_moder!   r!   r"   _prepare_vc   s   r@   c              
   C   sF   | sd S zt t| W S  ttfy" } z	td|  |d }~ww )Nz!Could not load certificates from )listr   r   
ValueErrorr   r   )filesr   r!   r!   r"   
grab_certs   s   rD   r5   )typingr   r   r   r   r   pyhanko_certvalidatorr   pyhanko.cli.configr   pyhanko.cli.utilsr   r	   pyhanko.config.errorsr
   pyhanko.config.trustr   pyhanko.keysr   strboolr#   Contextr)   Optionr8   Commandr1   r9   r@   rD   r!   r!   r!   r"   <module>   sv    

H	!