File: //lib/python3/dist-packages/docker/__pycache__/tls.cpython-310.pyc
o
    �2.a�  �                   @   s:   d dl Z d dlZddlmZ ddlmZ G dd� d�ZdS )�    N�   )�errors)�SSLHTTPAdapterc                   @   s8   e Zd ZdZdZdZdZdZ			ddd�Zdd� Z	dS )�	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|| _ntjd d� dkr!ttd�r!ttd�| _ntj| _|rTz|\}}W n ty9   t	�
d��w |rJ|rJtj�
|�rJtj�
|�sOt	�
d��||f| _|| _|| _| jrl| jrntj�
| j�spt	�
d��d S d S d S )N�   )r   r   r   �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�ssl�OPENSSL_VERSION_INFO�hasattr�getattr�PROTOCOL_TLSv1�
ValueErrorr   �TLSParameterError�os�path�isfile�cert�verify�ca_cert)	�self�client_certr   r   r
   r   r	   �tls_cert�tls_key� r   �,/usr/lib/python3/dist-packages/docker/tls.py�__init__   s>