U
    #S¬\á  ã                   @   s<   d dl Z d dlZddlmZ ddlmZ G dd„ deƒZdS )é    Né   )Úerrors)ÚSSLHTTPAdapterc                   @   s2   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|| _n2tjd d… dkrBttdƒrBttdƒ| _ntj| _|r®z|\}}W n tk
rx   t	 
d¡‚Y nX |rš|rštj |¡rštj |¡s¤t	 
d¡‚||f| _|| _|| _| jrÞ| jrÞtj | j¡sÞt	 
d¡‚d S )Né   )r   r   r   ZPROTOCOL_TLSv1_2z?client_config must be a tuple of (client certificate, key file)zTPath to a certificate and key files must be provided through the client_config paramz2Invalid CA certificate provided for `tls_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r4| 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   Úobjectr   r   r   r   r   Ú<module>   s   