File: //var/opt/nydus/ops/oscrypto/_openssl/__pycache__/tls.cpython-39.pyc
a
�,�h�� � @ s� d dl mZmZmZmZ d dlZd dlZd dlZd dl Z d dl
Z
ddlmZm
Z
ddlmZmZmZmZ ddlmZ ddlmZ dd lmZ dd
lmZmZmZmZmZ ddl m!Z!m"Z"m#Z#m$Z$ ddl%m&Z&m'Z'm(Z( dd
l)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z; ddl<m=Z=mZ ddl>m?Z? ddl@mAZA ejBdk �r\eCZDejBdk �rpejEZFnejFZFddgZGe� �Hd�ZIe�Jd�ZKe
jLe
jMe
jNe
jOe
jPd�ZQdd� ZRG dd� deS�ZTG dd� deS�ZUdS )� )�unicode_literals�division�absolute_import�print_functionN� )�libssl�LibsslConst)� libcrypto�libcrypto_version_info�handle_openssl_error�peek_openssl_error� )�_backend_config)�Certificate)�pretty_message)�null�bytes_from_buffer�buffer_from_bytes�is_null�buffer_pointer)� type_name�str_cls�byte_cls� int_types)�TLSError�TLSDisconnectError�TLSGracefulDisconnectError)�detect_client_auth_request�
extract_chain�get_dh_params_length�parse_session_info�raise_client_auth�raise_dh_params�raise_disconnection�raise_expired_not_yet_valid�raise_handshake�raise_hostname�raise_no_issuer�raise_protocol_error�raise_protocol_version�raise_self_signed�raise_verification�raise_weak_signature�parse_tls_records�parse_handshake_messages)�load_certificater )�parse_certificate)�get_path�� )r3 � �
TLSSession� TLSSocket�trust_list_paths (
|
|
))�SSLv2�SSLv3�TLSv1�TLSv1.1�TLSv1.2c C s t dk r| S | d d| d fS )a^
Takes a 3-element tuple from peek_openssl_error() and modifies it
to handle the changes in OpenSSL 3.0. That release removed the
concept of an error function, meaning the second item in the tuple
will always be 0.
:param error_tuple:
A 3-element tuple of integers
:return:
A 3-element tuple of integers
r2 r r
)r
)Zerror_tuple� r= �F/opt/nydus/tmp/pip-target-wkfpz8uv/lib/python/oscrypto/_openssl/tls.py�_homogenize_openssl3_errorD s r? c @ s: e Zd ZdZdZdZdZdZdZdZ ddd�Z
dd� ZdS ) r5 zj
A TLS session object that multiple TLSSocket objects can share for the
sake of session reuse
NFc C s� t |t�sttdt|����|| _|du r6tg d��}t |t�rLt|g�}nt |t�shttdt|����tg d��}|| }|r�ttdt |����|| _
g | _|�rD|D ]�}t |t�r�|j
}nxt |t�r�t|�}ndt |t��rt|d��}t|�� �}W d � n1 �s0 Y nt |t��s6ttdt|����| j�|� q�d}�z|td k �r`t�� } nt�� } t�| �}t|��r�td
� || _t�|d� t�|tjtj t!� � t"j#tdd
g�v �rt$}
|
du �r�t%� }
t"j#dk�r�d}nd}t�&||
�'|�t!� �}n
t�(|�}t|� |�r tj)ntj*}
t�+||
t!� � t�,|d�}t|� tdg�}||| j
O }|D ]}t�|tj-t.| t!� � �qf| j�r�t�/|�}| jD ]$}t0|�}t�1||j2�}t|� �q�W n, t3�y� |�r�t�4|� d| _� Y n0 dS )a]
:param protocol:
A unicode string or set of unicode strings representing allowable
protocols to negotiate with the server:
- "TLSv1.2"
- "TLSv1.1"
- "TLSv1"
- "SSLv3"
Default is: {"TLSv1", "TLSv1.1", "TLSv1.2"}
:param manual_validation:
If certificate and certificate path validation should be skipped
and left to the developer to implement
:param extra_trust_roots:
A list containing one or more certificates to be treated as trust
roots, in one of the following formats:
- A byte string of the DER encoded certificate
- A unicode string of the certificate filename
- An asn1crypto.x509.Certificate object
- An oscrypto.asymmetric.Certificate object
:raises:
ValueError - when any of the parameters contain an invalid value
TypeError - when any of the parameters are of the wrong type
OSError - when an error is returned by the OS crypto library
zM
manual_validation must be a boolean, not %s
N)r: r; r<