o
    2.a                     @   s:   d dl Z d dlZddlmZ ddlmZ G dd dZdS )    N   )errors)SSLHTTPAdapterc                   @   s8   e Zd ZdZdZdZdZdZ			dddZdd Z	dS )	TLSConfiga  
    TLS configuration.

    Args:
        client_cert (tuple of str): Path to client cert, path to client key.
        ca_cert (str): Path to CA cert file.
        verify (bool or str): This can be ``False`` or a path to a CA cert
            file.
        ssl_version (int): A valid `SSL version`_.
        assert_hostname (bool): Verify the hostname of the server.

    .. _`SSL version`:
        https://docs.python.org/3.5/library/ssl.html#ssl.PROTOCOL_TLSv1
    Nc           	      C   s   || _ || _|r|| _ntjd d dkr!ttdr!ttd| _ntj| _|rTz|\}}W n ty9   t	
dw |rJ|rJtj|rJtj|sOt	
d||f| _|| _|| _| jrl| jrntj| jspt	
dd S d S d S )N   )r   r   r   ZPROTOCOL_TLSv1_2z=client_cert must be a tuple of (client certificate, key file)zRPath to a certificate and key files must be provided through the client_cert paramz.Invalid CA certificate provided for `ca_cert`.)assert_hostnameassert_fingerprintssl_versionsslZOPENSSL_VERSION_INFOhasattrgetattrZPROTOCOL_TLSv1
ValueErrorr   ZTLSParameterErrorospathisfilecertverifyca_cert)	selfZclient_certr   r   r	   r   r   Ztls_certZtls_key r   ,/usr/lib/python3/dist-packages/docker/tls.py__init__   s>   	

zTLSConfig.__init__c                 C   sT   | j |_ | jr| jr| j|_n| j|_| jr| j|_|dt| j | j| jd dS )z<
        Configure a client with these TLS options.
        zhttps://)r	   r   r   N)r	   r   r   r   Zmountr   r   r   )r   Zclientr   r   r   configure_client^   s   
zTLSConfig.configure_client)NNNNNN)
__name__
__module____qualname____doc__r   r   r   r	   r   r   r   r   r   r   r      s    
Br   )r   r
    r   Z	transportr   r   r   r   r   r   <module>   s
    