Your IP : 18.119.134.196


Current Path : /opt/alt/python312/lib64/python3.12/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/__pycache__/ssl.cpython-312.opt-2.pyc

�

�Q�f���
�n�	ddlZddlZddlmZddlmZmZm	Z
ddlmZddlZddlm
Z
mZmZddlmZmZmZddlmZmZmZmZmZmZmZddlmZmZdd	lmZmZm Z 	dd
lm!Z!ddlm#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,ddlm-Z-m.Z.ej^d
e0d�e��e
j^de0d�e��ej^de0d�e��ej^de0d�e��e
j^de0d�e��ej^de0d�e��e1jdxZ3e1_3e1jhjk�D��cic]\}}||��
c}}Z6e7e1dd�Z8ee�Gd�d��Z9ee�Gd�d��Z:ee�Gd�d ��Z;ee�Gd!�d"��Z<ejzd#k(rdd$lm>Z>m?Z?dd%l@m@Z@mAZAmBZBdd&l@mCZCmDZDmEZEddl@ZFddlGZGddlHZHddlIZIeJZKd'gZLeMed(�ZNe-ZOeZPd)�ZQd*�ZRd+�ZSed,d-�ZTd.�ZUGd/�d0ed0d1��ZVGd2�d3eVe�ZWGd4�d5e�ZXeWj�fdddd6�d7�ZZdGe[d8eWj�dddddd9�d:�Z\eZZ]e\Z^Gd;�d<�Z_d=�Z`Gd>�d?e@�ZaeaeX_be_eX_cd@�ZddAZedBZfdC�ZgdD�ZheideEfdE�ZjdF�Zky#e"$rY��JwxYwcc}}w)H�N)�
namedtuple)�Enum�IntEnum�IntFlag)�_simple_enum)�OPENSSL_VERSION_NUMBER�OPENSSL_VERSION_INFO�OPENSSL_VERSION)�_SSLContext�	MemoryBIO�
SSLSession)�SSLError�SSLZeroReturnError�SSLWantReadError�SSLWantWriteError�SSLSyscallError�SSLEOFError�SSLCertVerificationError)�txt2obj�nid2obj)�RAND_status�RAND_add�
RAND_bytes)�RAND_egd)
�HAS_SNI�HAS_ECDH�HAS_NPN�HAS_ALPN�	HAS_SSLv2�	HAS_SSLv3�	HAS_TLSv1�HAS_TLSv1_1�HAS_TLSv1_2�HAS_TLSv1_3)�_DEFAULT_CIPHERS�_OPENSSL_API_VERSION�
_SSLMethodc�2�|jd�xr|dk7S)N�	PROTOCOL_�PROTOCOL_SSLv23��
startswith��names �*/opt/alt/python312/lib64/python3.12/ssl.py�<lambda>r0}s������-�K�$�:K�2K�K�)�source�Optionsc�$�|jd�S)N�OP_r+r-s r/r0r0�s
������'r1�AlertDescriptionc�$�|jd�S)N�ALERT_DESCRIPTION_r+r-s r/r0r0�s�����!5�6r1�SSLErrorNumberc�$�|jd�S)N�
SSL_ERROR_r+r-s r/r0r0�s
������.r1�VerifyFlagsc�$�|jd�S)N�VERIFY_r+r-s r/r0r0�s
������+r1�
VerifyModec�$�|jd�S)N�CERT_r+r-s r/r0r0�s
������)r1�PROTOCOL_SSLv2c��eZdZejZejZejZ	ejZejZ
ejZej Zy)�
TLSVersionN)�__name__�
__module__�__qualname__�_ssl�PROTO_MINIMUM_SUPPORTED�MINIMUM_SUPPORTED�PROTO_SSLv3�SSLv3�PROTO_TLSv1�TLSv1�
PROTO_TLSv1_1�TLSv1_1�
PROTO_TLSv1_2�TLSv1_2�
PROTO_TLSv1_3�TLSv1_3�PROTO_MAXIMUM_SUPPORTED�MAXIMUM_SUPPORTED�r1r/rDrD�sQ���4�4�����E����E�� � �G�� � �G�� � �G��4�4�r1rDc�&�eZdZ	dZdZdZdZdZdZy)�_TLSContentType������N)	rErFrG�CHANGE_CIPHER_SPEC�ALERT�	HANDSHAKE�APPLICATION_DATA�HEADER�INNER_CONTENT_TYPErWr1r/rYrY�s*������E��I���
�F��r1rYc��eZdZ	dZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#d"Z$y#)$�
_TLSAlertTyper�
rZr[r\��(�)�*�+�,�-�.�/�0�1�2�3�<�F�G�P�V�Z�d�m�n�o�p�q�r�s�t�xN)%rErFrG�CLOSE_NOTIFY�UNEXPECTED_MESSAGE�BAD_RECORD_MAC�DECRYPTION_FAILED�RECORD_OVERFLOW�DECOMPRESSION_FAILURE�HANDSHAKE_FAILURE�NO_CERTIFICATE�BAD_CERTIFICATE�UNSUPPORTED_CERTIFICATE�CERTIFICATE_REVOKED�CERTIFICATE_EXPIRED�CERTIFICATE_UNKNOWN�ILLEGAL_PARAMETER�
UNKNOWN_CA�
ACCESS_DENIED�DECODE_ERROR�
DECRYPT_ERROR�EXPORT_RESTRICTION�PROTOCOL_VERSION�INSUFFICIENT_SECURITY�INTERNAL_ERROR�INAPPROPRIATE_FALLBACK�
USER_CANCELED�NO_RENEGOTIATION�MISSING_EXTENSION�UNSUPPORTED_EXTENSION�CERTIFICATE_UNOBTAINABLE�UNRECOGNIZED_NAME�BAD_CERTIFICATE_STATUS_RESPONSE�BAD_CERTIFICATE_HASH_VALUE�UNKNOWN_PSK_IDENTITY�CERTIFICATE_REQUIRED�NO_APPLICATION_PROTOCOLrWr1r/rgrg�s�����L����N����O������N��O� �����������J��M��L��M��������N����M�������"����&)�#�!$������!�r1rgc�f�eZdZ	dZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZy)�_TLSMessageTyper����������
���rZr[r\r]��C�r_N)rErFrG�
HELLO_REQUEST�CLIENT_HELLO�SERVER_HELLO�HELLO_VERIFY_REQUEST�NEWSESSION_TICKET�END_OF_EARLY_DATA�HELLO_RETRY_REQUEST�ENCRYPTED_EXTENSIONS�CERTIFICATE�SERVER_KEY_EXCHANGE�CERTIFICATE_REQUEST�SERVER_DONE�CERTIFICATE_VERIFY�CLIENT_KEY_EXCHANGE�FINISHED�CERTIFICATE_URL�CERTIFICATE_STATUS�SUPPLEMENTAL_DATA�
KEY_UPDATE�
NEXT_PROTO�MESSAGE_HASHr`rWr1r/r�r��s�����M��L��L������������K������K������H��O������J��J��L��r1r��win32)�enum_certificates�	enum_crls)�socket�SOCK_STREAM�create_connection)�
SOL_SOCKET�SO_TYPE�_GLOBAL_DEFAULT_TIMEOUT�
tls-unique�HOSTFLAG_NEVER_CHECK_SUBJECTc��	|sy|jd�}|s!|j�|j�k(S|dkDrtdj|���|j	d�\}}}d|vrtdj|���|stdj|���|dk7rtdj|���|j	d�\}}}|r|sy|j�|j�k(S)	NF�*r�z1too many wildcards in certificate DNS name: {!r}.�.z9wildcard can only be present in the leftmost label: {!r}.z>sole wildcard without additional labels are not support: {!r}.z<partial wildcards in leftmost label are not supported: {!r}.)�count�lower�CertificateError�format�	partition)�dn�hostname�	wildcards�dn_leftmost�sep�dn_remainder�hostname_leftmost�hostname_remainders        r/�_dnsname_matchr�s���������
�I���x�x�z�X�^�^�-�-�-��1�}��?�F�F�r�J�L�	L�&(�\�\�#�%6�"�K��l�
�l���
��F�2�J� �	 ���
��F�2�J� �	 ��c���
��F�2�J� �	 �2:�1C�1C�C�1H�.��s�.��C������#5�#;�#;�#=�=�=r1c��		tj|�}tj|�|k(r|Stdj	|���#t
$rYnwxYw	tjtj|�S#t
$rtdj	|���t$rYnwxYwtdj	|���)Nz'{!r} is not a quad-dotted IPv4 address.z+{!r} is neither an IPv4 nor an IP6 address.z{!r} is not an IPv4 address.)	�_socket�	inet_aton�	inet_ntoa�
ValueErrorr��OSError�	inet_pton�AF_INET6�AttributeError)�ipname�addrs  r/�_inet_patonr�Is����
�� � ��(��
���T�"�f�,��K��9�@�@��H��
���
��
��
�� � ��!1�!1�6�:�:���4��$�$*�F�6�N�4�	4��
��
���3�:�:�6�B�
C�Cs#�A�	A�A�#B�+B.�-B.c�@�	t|j��}||k(S�N)r��rstrip)�cert_ipaddress�host_ip�ips   r/�_ipaddress_matchr�ls&���
�^�*�*�,�	-�B�
��=�r1�DefaultVerifyPathszQcafile capath openssl_cafile_env openssl_cafile openssl_capath_env openssl_capathc�b�	tj�}tjj	|d|d�}tjj	|d|d�}ttjj|�r|ndtjj|�r|ndg|���S)Nrr�r�r�)	rH�get_default_verify_paths�os�environ�getr��path�isfile�isdir)�parts�cafile�capaths   r/rr|s�����)�)�+�E��Z�Z�^�^�E�!�H�e�A�h�
/�F�
�Z�Z�^�^�E�!�H�e�A�h�
/�F�������v�(>�f�D�(*���
�
�f�(=�f�4�&�$�&�&r1c�L��eZdZ	dZ�fd�Ze�fd��Ze�fd��Z�xZS)�_ASN1ObjectrWc�:��t�|�|gt|d�����S)NFr-��super�__new__�_txt2obj)�cls�oid�	__class__s  �r/rz_ASN1Object.__new__�s����w��s�?�X�c��%>�?�?r1c�8��	t�|�|gt|����Sr�)rr�_nid2obj)r�nidrs  �r/�fromnidz_ASN1Object.fromnid�s ���	��w��s�3�X�c�]�3�3r1c�<��	t�|�|gt|d�����S)NTr-r
)rr.rs  �r/�fromnamez_ASN1Object.fromname�s#���	��w��s�?�X�d��%>�?�?r1)	rErFrG�	__slots__r�classmethodrr�
__classcell__�rs@r/rr�s=�����I�@��4��4�
�@��@r1rznid shortname longname oidc��eZdZ	dZdZy)�Purposez1.3.6.1.5.5.7.3.1z1.3.6.1.5.5.7.3.2N)rErFrG�SERVER_AUTH�CLIENT_AUTHrWr1r/rr�s���%�K�%�Kr1rc�h��eZdZ	dZdZdZdd�Zd�Z				dd�Z		d d�Z	d�Z
d�Zd	�Zd
�Z
ejfd�Zeed�r<e�fd
��Zej*�fd��Ze�fd��Zej*�fd��Ze�fd��Zej*�fd��Zeed�red��Zej*d��Zned��Ze�fd��Zej*�fd��Ze�fd��Ze�fd��Zej*�fd��Ze�fd��Zej*�fd��Z�xZS)!�
SSLContext)�CA�ROOTNc�z�|�"tjdtd��t}t	j
||�}|S)Nz9ssl.SSLContext() without protocol argument is deprecated.r�)�category�
stacklevel)�warnings�warn�DeprecationWarning�PROTOCOL_TLSrr)r�protocol�args�kwargs�selfs     r/rzSSLContext.__new__�s;�����M�M�K�+��
�
$�H��"�"�3��1���r1c��|�yt|t�r |jd�jd�S|jd�S)N�idna�ascii)�
isinstance�str�encode�decode)r0r�s  r/�_encode_hostnamezSSLContext._encode_hostname�s>�����
��#�
&��?�?�6�*�1�1�'�:�:��?�?�7�+�+r1c	�F�|jj|||||||��S)N)�sock�server_side�do_handshake_on_connect�suppress_ragged_eofs�server_hostname�context�session)�sslsocket_class�_create)r0r:r;r<r=r>r@s       r/�wrap_socketzSSLContext.wrap_socket�s7���#�#�+�+��#�$;�!5�+���,�
�	
r1c�b�|jj||||j|�||��S)N)r;r>r@r?)�sslobject_classrBr8)r0�incoming�outgoingr;r>r@s      r/�wrap_biozSSLContext.wrap_bio�s<���#�#�+�+��h�K� �1�1�/�B��T�,�
�	
r1c�<�tjdtd��t�}|D]`}t	|d�}t|�dk(st|�dkDrt
d��|jt|��|j|��b|j|�y)N�'ssl NPN is deprecated, use ALPN insteadr��r(r3r�z(NPN protocols must be 1 to 255 in length)
r)r*r+�	bytearray�bytes�lenr�append�extend�_set_npn_protocols)r0�
npn_protocols�protosr-�bs     r/�set_npn_protocolszSSLContext.set_npn_protocols�s����
�
�5���	
�
���%�H��h��(�A��1�v��{�c�!�f�s�l��I�J�J��M�M�#�a�&�!��M�M�!��&�	
����'r1c�b�����d�_yt��std����fd�}|�_y)Nznot a callable objectc�:���j|�}�|||�Sr�)r8)�sslobj�
servername�sslctxr0�server_name_callbacks   ��r/�shim_cbz3SSLContext.set_servername_callback.<locals>.shim_cb�s"���!�2�2�:�>�
�+�F�J��G�Gr1)�sni_callback�callable�	TypeError)r0r\r]s`` r/�set_servername_callbackz"SSLContext.set_servername_callback�s6����'� $�D���0�1�� 7�8�8�
H�!(�D�r1c��t�}|D]`}t|d�}t|�dk(st|�dkDrtd��|j	t|��|j|��b|j
|�y)Nr3rrLz)ALPN protocols must be 1 to 255 in length)rMrNrOrrPrQ�_set_alpn_protocols)r0�alpn_protocolsrTr-rUs     r/�set_alpn_protocolszSSLContext.set_alpn_protocols�sl�����&�H��h��(�A��1�v��{�c�!�f�s�l��J�K�K��M�M�#�a�&�!��M�M�!��'�	
� � ��(r1c�*�	t|�D]2\}}}|dk(s�
|dus|j|vs� 	|j|���4y#t$r"}t	j
d|���Yd}~�\d}~wwxYw#t$rt	j
d�YywxYw)N�x509_asnT)�cadataz.Bad certificate in Windows certificate store: z-unable to enumerate Windows certificate store)r�r�load_verify_locationsrr)r*�PermissionError)r0�	storename�purpose�cert�encoding�trust�excs       r/�_load_windows_store_certsz$SSLContext._load_windows_store_certss���
	K�):�9�)E�%��h���z�)���}����u�(<�d� �6�6�d�6�C�*F�� (�d�$�M�M�,Z�[^�Za�*b�c�c��d���	K��M�M�I�J�	K�s?�A1�A1�A�A1�	A.�A)�$A1�)A.�.A1�1B�Bc���t|t�st|��tjdk(r#|j
D]}|j
||��|j�y)Nr�)r4rr`�sys�platform�_windows_cert_storesrq�set_default_verify_paths)r0rlrks   r/�load_default_certszSSLContext.load_default_certssO���'�;�/��G�$�$��<�<�7�"�!�6�6�	��.�.�y�'�B�7��%�%�'r1�minimum_versionc�*��tt�|��Sr�)rDrrx�r0rs �r/rxzSSLContext.minimum_version�����e�g�5�6�6r1c���|tjk(r$|xjtjzc_t
tt�j||�yr�)	rDrL�optionsr3�OP_NO_SSLv3rr#rx�__set__�r0�valuers  �r/rxzSSLContext.minimum_versions?����
�(�(�(�����!4�!4� 4�4���*�j�9�A�A�$��Nr1c�*��tt�|��Sr�)rDr�maximum_versionrzs �r/r�zSSLContext.maximum_version#r{r1c�J��ttt�
j||�yr�)rr#r�rr�s  �r/r�zSSLContext.maximum_version's����*�j�9�A�A�$��Nr1c�*��tt�|��Sr�)r3rr}rzs �r/r}zSSLContext.options+s����u�w��'�'r1c�J��ttt�
j||�yr�)rr#r}rr�s  �r/r}zSSLContext.options/s���
�j�*�-�5�5�d�E�Br1r�c�b�|jtjz}|tjk7Sr���_host_flagsrHr�)r0�ncss  r/�hostname_checks_common_namez&SSLContext.hostname_checks_common_name4s)���"�"�T�%F�%F�F�C��$�;�;�;�;r1c��|r%|xjtjzc_y|xjtjzc_yr�r�)r0r�s  r/r�z&SSLContext.hostname_checks_common_name9s6���� � �T�%F�%F�$F�F� �� � �D�$E�$E�E� r1c��y�NTrW�r0s r/r�z&SSLContext.hostname_checks_common_name@s��r1c�8��	t�|�}|�|jSyr�)r�
_msg_callback�
user_function)r0�innerrs  �r/r�zSSLContext._msg_callbackDs)���	�>��%�����&�&�&�r1c�������#ttt�
j|d�yt	�d�st��d����fd�}�|_ttt�
j||�y)N�__call__z is not callable.c�.��	t|�}	t|�}|tjk(rt}n |tjk(rt
}nt}	||�}�||||||�S#t$rY�gwxYw#t$rY�jwxYw#t$rY�6wxYwr�)rDr�rYrdrargr�)�conn�	direction�version�content_type�msg_type�data�msg_enum�callbacks       �r/r�z'SSLContext._msg_callback.<locals>.innerts����
�$�W�-��
�.�|�<����5�5�5�*����!6�!6�6�(��*��
�#�H�-���D�)�W�(�(�D�:�
:��'�
��
��
�
��
���
��
�s4�A*�A9�B�*	A6�5A6�9	B�B�	B�B)rr#r�r�hasattrr`r�)r0r�r�rs ` �r/r�zSSLContext._msg_callbackksf������*�j�7�?�?��d�K���x��,��x�j�(9�:�;�;�	:�2'���
�j�*�3�;�;�D�%�Hr1c�*��tt�|��Sr�)r'rr-rzs �r/r-zSSLContext.protocol�s����%�'�*�+�+r1c�*��tt�|��Sr�)r<r�verify_flagsrzs �r/r�zSSLContext.verify_flags�s����5�7�/�0�0r1c�J��ttt�
j||�yr�)rr#r�rr�s  �r/r�zSSLContext.verify_flags�s���
�j�*�2�:�:�4��Gr1c�R��t�|�}	t|�S#t$r|cYSwxYwr�)r�verify_moder?r�r�s  �r/r�zSSLContext.verify_mode�s1�����#��	��e�$�$���	��L�	�s�
�&�&c�J��ttt�
j||�yr�)rr#r�rr�s  �r/r�zSSLContext.verify_mode�s���
�j�*�1�9�9�$��Fr1r�)FTTNN)FNN)rErFrGrurArErr8rCrHrVrarerqrr rwr�r�propertyrx�setterr�r}rHr�r�r-r�r�rrs@r/r#r#�s����>�)���O��O�	�,�-2�,0�)-�26�
� 8=�/3�
�(� (�	)�K�*1�)<�)<�(��{�-�.�	�	7�
�	7�
�	�	�	O�
 �	O�

�	7�
�	7�
�	�	�	O�
 �	O��(��(�
�^�^�C��C��t�3�4�	�	<�
�	<�
%�	+�	+�	F�
,�	F�
�	�
�	��$��$�L���#I��#I�J�,��,��1��1����H��H��������G��Gr1r#)rr	rhc��	t|t�st|��|tjk(r"tt�}t|_d|_	n.|tjk(rtt�}nt|��|s|s|r|j|||�n$|jtk7r|j|�t!|d�rBt"j$j'd�}|r!t(j*j,s||_|S)NT�keylog_filename�
SSLKEYLOGFILE)r4rr`rr r#�PROTOCOL_TLS_CLIENT�
CERT_REQUIREDr��check_hostnamer!�PROTOCOL_TLS_SERVERr�ri�	CERT_NONErwr�rrrrs�flags�ignore_environmentr�)rlrr	rhr?�
keylogfiles      r/�create_default_contextr��s�����g�{�+��� � �
�'�%�%�%��0�1��+���!%���	�G�'�'�	'��0�1����!�!�
��6��%�%�f�f�f�=�	�	�	�	�	)�	�"�"�7�+��w�)�*��Z�Z�^�^�O�4�
��c�i�i�:�:�&0�G�#��Nr1F)�	cert_reqsr�rl�certfile�keyfilerr	rhc�n�	t|t�st|��|tjk(r	|�.t
}n'|tjk(r	|�t}nt|��t|�}	||	_
|�||	_|rd|	_
|r
|std��|s|r|	j||�|s|s|r|	j|||�n$|	jtk7r|	j|�t!|	d�rBt"j$j'd�}
|
r!t(j*j,s|
|	_|	S)NTzcertfile must be specifiedr�r�)r4rr`rr r�r!r�r�r#r�r��load_cert_chainrir�rwr�rrrrsr�r�r�)r-r�r�rlr�r�rr	rhr?r�s           r/�_create_unverified_contextr��s ����g�{�+��� � �
�'�%�%�%���*�H�	�G�'�'�	'���*�H���!�!���"�G�+�G����'����!%����x��5�6�6��7�����'�2���6��%�%�f�f�f�=�	�	�	�	�	)�	�"�"�7�+��w�)�*��Z�Z�^�^�O�4�
��c�i�i�:�:�&0�G�#��Nr1c��eZdZ	d�Ze		dd��Zed��Zejd��Zed��Z	e	jd��Z	ed��Z
ed	��Zed
��Zdd�Z
d�Zdd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zd�Zd�Zy)�	SSLObjectc�F�t|jj�d���)NzU does not have a public constructor. Instances are returned by SSLContext.wrap_bio().�r`rrE�r0r.r/s   r/�__init__zSSLObject.__init__s+����~�~�&�&�'�(L�
M�
�	
r1Nc�d�|j|�}|j||||||��}||_|S)N)r;r>�ownerr@)r�	_wrap_bio�_sslobj)	rrFrGr;r>r@r?r0rYs	         r/rBzSSLObject._create#sD���{�{�3����"�"��h�K�+���#�
��
����r1c�0�	|jjSr��r�r?r�s r/r?zSSLObject.context/s��6��|�|�#�#�#r1c�&�||j_yr�r��r0�ctxs  r/r?zSSLObject.context4s��"����r1c�0�	|jjSr��r�r@r�s r/r@zSSLObject.session8s��/��|�|�#�#�#r1c�&�||j_yr�r��r0r@s  r/r@zSSLObject.session=s��&����r1c�0�	|jjSr��r��session_reusedr�s r/r�zSSLObject.session_reusedAs��<��|�|�*�*�*r1c�0�	|jjSr�)r�r;r�s r/r;zSSLObject.server_sideFs��3��|�|�'�'�'r1c�0�	|jjSr�)r�r>r�s r/r>zSSLObject.server_hostnameKs��	#��|�|�+�+�+r1c�~�	|�|jj||�}|S|jj|�}|Sr�)r��read)r0rO�buffer�vs    r/r�zSSLObject.readQsG��	�
�����!�!�#�v�.�A������!�!�#�&�A��r1c�:�	|jj|�Sr�)r��write�r0r�s  r/r�zSSLObject.write]s��	�
�|�|�!�!�$�'�'r1c�:�	|jj|�Sr�)r��getpeercert�r0�binary_forms  r/r�zSSLObject.getpeercertes��	��|�|�'�'��4�4r1c�>�	tjdtd��y�NrJr�rK)r)r*r+r�s r/�selected_npn_protocolzSSLObject.selected_npn_protocolns��	�	�
�
�5���	
r1c�8�	|jj�Sr�)r��selected_alpn_protocolr�s r/r�z SSLObject.selected_alpn_protocolxs��	��|�|�2�2�4�4r1c�8�	|jj�Sr�)r��cipherr�s r/r�zSSLObject.cipher~s��	(��|�|�"�"�$�$r1c�8�	|jj�Sr�)r��shared_ciphersr�s r/r�zSSLObject.shared_ciphers�s��	��|�|�*�*�,�,r1c�8�	|jj�Sr�)r��compressionr�s r/r�zSSLObject.compression�s��	P��|�|�'�'�)�)r1c�8�	|jj�Sr�)r��pendingr�s r/r�zSSLObject.pending�s��F��|�|�#�#�%�%r1c�:�	|jj�yr�)r��do_handshaker�s r/r�zSSLObject.do_handshake�s��*����!�!�#r1c�8�	|jj�Sr�)r��shutdownr�s r/�unwrapzSSLObject.unwrap�s��/��|�|�$�$�&�&r1c�:�	|jj|�Sr�)r��get_channel_binding�r0�cb_types  r/r�zSSLObject.get_channel_binding�s��	M��|�|�/�/��8�8r1c�8�	|jj�Sr��r�r�r�s r/r�zSSLObject.version�s��	!��|�|�#�#�%�%r1c�6�|jj�Sr�)r��verify_client_post_handshaker�s r/r�z&SSLObject.verify_client_post_handshake�s���|�|�8�8�:�:r1)FNNN��N�F�r�)rErFrGr�rrBr�r?r�r@r�r;r>r�r�r�r�r�r�r�r�r�r�r�r�r�r�rWr1r/r�r�s��
�
��5:�=A�	��	��$��$�
�^�^�#��#��$��$�
�^�^�'��'��+��+��(��(��,��,�

�(�5�
�5�%�
-�*�
&�$�'�9�&�
;r1r�c�Z�	tt|j�j|_|Sr�)�getattrr�rE�__doc__)�funcs r/�_sslcopydocr�s"��4��9�d�m�m�4�<�<�D�L��Kr1c�\��eZdZ	d�Ze			d*�fd�	�Zeed���Zejd��Zeed���Z
e
jd��Z
eed���Zd�Zd+d	�Z
d
�Zd,d�Zd�Zed-d
��Zed��Zed��Zed��Zed��Zed��Zd.�fd�	Zd+�fd�	Zd�Zd.�fd�	Zd/�fd�	Zd0�fd�	Zd1�fd�	Zd0�fd�	Zd1�fd�	Zd�Z d�Z!ed��Z"�fd�Z#ed ��Z$ed!��Z%�fd"�Z&ed-d#��Z'�fd$�Z(d%�Z)d&�Z*�fd'�Z+ed2d(��Z,ed)��Z-�xZ.S)3�	SSLSocketc�F�t|jj�d���)NzX does not have a public constructor. Instances are returned by SSLContext.wrap_socket().r�r�s   r/r�zSSLSocket.__init__�s)����~�~�&�&�'�((�
)�
�	
r1c���|jtt�tk7rt	d��|r|rtd��|�td��|jr
|std��|j�}t|j|j|j|j���}	|j|fi|	��}
tt|
�Bdi|	��|j#�	||
_||
_d|
_d|
_||
_|j/|�|
_||
_||
_	|
j7�d}|
jM|�||
_'|rk|
j$jQ|
||
j0|
|
j&��|
_|r0|
j�}|dk(rtd
��|
jS�|
S#t8$r�}|j:t:j<k7r�d}|
j?�}
|
jAd�	|
jCd�}nE#t8$r9}|j:t:j<t:jDfvr�d	}Yd}~nd}~wwxYw|
jA|
�|r0d
}tGj:|�}||_$d|_%	|�#d}wxYwYd}~��rd}~wwxYw#	|
jU��#t8$rY�wxYwxYw)Nz!only stream sockets are supportedz4server_hostname can only be specified in client modez,session can only be specified in client modez'check_hostname requires server_hostname)�family�type�proto�filenoFTr�r1z5Closed before TLS handshake with data in recv buffer.�r�r@�zHdo_handshake_on_connect should not be specified for non-blocking socketsrW)+�
getsockoptr�r�r��NotImplementedErrorr�r��
gettimeout�dictrrrrrrrr��detach�_context�_session�_closedr�r;r8r>r<r=�getpeernamer��errno�ENOTCONN�getblocking�setblocking�recv�EINVALr�reason�library�
settimeout�
_connected�_wrap_socketr��close)rr:r;r<r=r>r?r@�sock_timeoutr/r0�	connected�e�blocking�notconn_pre_handshake_datar� notconn_pre_handshake_data_error�timeoutrs                  �r/rBzSSLSocket._create�s�����?�?�:�w�/�;�>�%�&I�J�J��� �"2�3�3��"� �"/�0�0��!�!�/��F�G�G����(����;�;�T�Y�Y�d�j�j��;�;�=�
���s�{�{�3�)�&�)��
�i��'�1�&�1����
�C	�#�D�M�#�D�M� �D�L��D�L�*�D��#*�#;�#;�O�#L�D� �+B�D�(�(<�D�%�#
!�� � �"�D!�	��O�O�L�)�'�D�O��#�}�}�9�9��+�t�';�';���
�
� :� ���+�"�o�o�/�G��#�~�(�)s�t�t��%�%�'����o�
@��7�7�e�n�n�,��!�	��+�+�-��� � ��'�
5�
26���1��.���5��w�w�u�~�~�u�|�|�&D�D��14�.��	5��
� � ��*�-�U�F�7?�����7P�4�>D�4�;�?C�4�<�@�>�>��<@�8��.��%
@��b	�
��
�
��
���
���
�s��%AJ9�-G�=BJ9�	J6�AJ1�H#�"J1�#	I%�,/I �J1� I%�%<J1�"J$�$J(�(J1�+J9�1J6�6J9�9K�<K
�K�
	K�K�K�Kc��|jSr�)rr�s r/r?zSSLSocket.contexts���}�}�r1c�4�||_||j_yr�)rr�r?r�s  r/r?zSSLSocket.contexts����
�"����r1c�H�|j�|jjSyr�r�r�s r/r@zSSLSocket.session$s#���<�<�#��<�<�'�'�'�$r1c�N�||_|j�||j_yyr�)rr�r@r�s  r/r@zSSLSocket.session*s$����
��<�<�#�#*�D�L�L� �$r1c�H�|j�|jjSyr�r�r�s r/r�zSSLSocket.session_reused0s#���<�<�#��<�<�.�.�.�$r1c�F�td|jjz��)NzCan't dup() %s instances)rrrEr�s r/�dupz
SSLSocket.dup6s$��!�"<�"&�.�.�"9�"9�#:�;�	;r1c��yr�rW)r0�msgs  r/�_checkClosedzSSLSocket._checkClosed:s��r1c�>�|js|j�yyr�)rrr�s r/�_check_connectedzSSLSocket._check_connected>s�����

����r1c�F�	|j�|j�td��	|�|jj||�S|jj|�S#t$r4}|j
dtk(r|jr|�Yd}~yYd}~y�d}~wwxYw)Nz'Read on closed or unwrapped SSL socket.rr1)r0r�r�r�rr.�
SSL_ERROR_EOFr=)r0rOr��xs    r/r�zSSLSocket.readFs���	-�	
�����<�<���F�G�G�	��!��|�|�(�(��f�5�5��|�|�(�(��-�-���	��v�v�a�y�M�)�d�.G�.G��%�����	�s#�A#�A#�#	B �,$B�B�B c��	|j�|j�td��|jj|�S)Nz(Write on closed or unwrapped SSL socket.)r0r�r�r�r�s  r/r�zSSLSocket.write[s@��	9�	
�����<�<���G�H�H��|�|�!�!�$�'�'r1c�x�|j�|j�|jj|�Sr�)r0r2r�r�r�s  r/r�zSSLSocket.getpeercertds/�����������|�|�'�'��4�4r1c�\�|j�tjdtd��yr�)r0r)r*r+r�s r/r�zSSLSocket.selected_npn_protocoljs(�������
�
�5���	
�
r1c��|j�|j�tjsy|jj	�Sr�)r0r�rHrr�r�s r/r�z SSLSocket.selected_alpn_protocolts4�������<�<��t�}�}���<�<�6�6�8�8r1c�p�|j�|j�y|jj�Sr�)r0r�r�r�s r/r�zSSLSocket.cipher|s.�������<�<����<�<�&�&�(�(r1c�p�|j�|j�y|jj�Sr�)r0r�r�r�s r/r�zSSLSocket.shared_ciphers�s.�������<�<����<�<�.�.�0�0r1c�p�|j�|j�y|jj�Sr�)r0r�r�r�s r/r�zSSLSocket.compression�s.�������<�<����<�<�+�+�-�-r1c����|j�|j�8|dk7rtd|jz��|jj	|�St
�|�||�S)Nrz3non-zero flags not allowed in calls to send() on %s)r0r�r�rr�r�send)r0r�r�rs   �r/r>zSSLSocket.send�sd��������<�<�#���z� �I��N�N�#�$�$��<�<�%�%�d�+�+��7�<��e�,�,r1c���|j�|j�td|jz��|�t�|�||�St�|�|||�S)Nz%sendto not allowed on instances of %s)r0r�r�rr�sendto)r0r��
flags_or_addrr�rs    �r/r@zSSLSocket.sendto�s^��������<�<�#��D�!�^�^�,�-�
-�
�\��7�>�$�
�6�6��7�>�$�
�t�<�<r1c�2�td|jz��)Nz&sendmsg not allowed on instances of %s�rrr�s   r/�sendmsgzSSLSocket.sendmsg�s ��"�"J�"&�.�.�#1�2�	2r1c���|j�|j�}|dk7rtd|jz��d}t	|�5}|jd�5}t
|�}||kr|j||d�}||z
}||kr�ddd�ddd�yt�|�%||�S#1swY�"xYw#1swYyxYw)Nrz6non-zero flags not allowed in calls to sendall() on %s�B)
r0r�r�r�
memoryview�castrOr>r�sendall)	r0r�r�r��view�	byte_view�amountr�rs	        �r/rIzSSLSocket.sendall�s���������<�<�#���z� �L��N�N�#�$�$��E��D�!�T�4�9�9�S�>�Y��Y����f�n��	�	�)�E�F�"3�4�A��Q�J�E��f�n�,:�!�!��7�?�4��/�/�
,:�>��!�!�s$�B7�/B+�
B7�+B4	�0B7�7Cc�f��	|j�|j|||�St�|�
|||�Sr�)r��_sendfile_use_sendr�sendfile)r0�file�offsetr�rs    �r/rOzSSLSocket.sendfile�s?���	��<�<�#��*�*�4���?�?��7�#�D�&�%�8�8r1c���|j�|j�.|dk7rtd|jz��|j	|�St
�|�||�S)Nrz3non-zero flags not allowed in calls to recv() on %s)r0r�r�rr�rr�r0�buflenr�rs   �r/rzSSLSocket.recv�s^��������<�<�#���z� �I��N�N�#�$�$��9�9�V�$�$��7�<���.�.r1c�*��|j�|�)|�%t|�5}|j}ddd�|sd}nd}|j�/|dk7rt	d|j
z��|j
||�St�|�!|||�S#1swY�\xYw)Nr�rz8non-zero flags not allowed in calls to recv_into() on %s)	r0rG�nbytesr�r�rr�r�	recv_into)r0r�rVr�rJrs     �r/rWzSSLSocket.recv_into�s���������>��!���'�4�!�[�[�F�(��!�F����<�<�#���z� �L��.�.�!�"�"��9�9�V�V�,�,��7�$�V�V�U�;�;�(�'�s�
B	�	Bc���|j�|j�td|jz��t�|�||�S)Nz'recvfrom not allowed on instances of %s)r0r�r�rr�recvfromrSs   �r/rYzSSLSocket.recvfrom�sI��������<�<�#��F�!�^�^�,�-�
-��7�#�F�E�2�2r1c���|j�|j�td|jz��t�|�|||�S)Nz,recvfrom_into not allowed on instances of %s)r0r�r�rr�
recvfrom_into)r0r�rVr�rs    �r/r[zSSLSocket.recvfrom_into�sK��������<�<�#��K�!�^�^�,�-�
-��7�(����?�?r1c�2�td|jz��)Nz&recvmsg not allowed on instances of %srCr�s   r/�recvmsgzSSLSocket.recvmsg�s��!�"J�"&�.�.�#1�2�	2r1c�2�td|jz��)Nz+recvmsg_into not allowed on instances of %srCr�s   r/�recvmsg_intozSSLSocket.recvmsg_into�s ��!�#'�)-���#8�9�	9r1c�p�|j�|j�|jj�Sy�Nr)r0r�r�r�s r/r�zSSLSocket.pending�s.�������<�<�#��<�<�'�'�)�)�r1c�R��|j�d|_t�|�
|�yr�)r0r�rr�)r0�howrs  �r/r�zSSLSocket.shutdowns#����������
����r1c��|jr#|jj�}d|_|Stdt|�z���NzNo SSL wrapper around )r�r�r�r5)r0�ss  r/r�zSSLSocket.unwraps<���<�<����%�%�'�A��D�L��H��5��D�	�A�B�Br1c�|�|jr|jj�Stdt|�z��re)r�r�r�r5r�s r/r�z&SSLSocket.verify_client_post_handshakes1���<�<��<�<�<�<�>�>��5��D�	�A�B�Br1c�0��d|_t�|�	�yr�)r�r�_real_closerzs �r/rizSSLSocket._real_closes������
���r1c��|j�|j�}	|dk(r|r|jd�|jj	�|j|�y#|j|�wxYw)Nr
)r2r
rr�r�)r0�blockr&s   r/r�zSSLSocket.do_handshake s]�������/�/�#��	%��#�~�%�����%��L�L�%�%�'��O�O�G�$��D�O�O�G�$�s�2A&�&A9c���|jrtd��|js|j�td��|jj|d|j||j��|_	|rt�|�%|�}nd}t�|�)|�|s#d|_|jr|j�|S#ttf$r	d|_�wxYw)Nz!can't connect in server-side modez/attempt to connect already-connected SSLSocket!Fr	T)r;r�rr�r?rr>rr�
connect_ex�connectr<r�r�)r0r�rm�rcrs    �r/�
_real_connectzSSLSocket._real_connect+s��������@�A�A��?�?�d�l�l�6��N�O�O��|�|�0�0��%��-�-���
�
�1�
���
	���W�'��-��������%��"&����/�/��%�%�'��I����$�	��D�L��	�s
�6A	C�Cc�*�	|j|d�y)NF�rp�r0r�s  r/rnzSSLSocket.connectEs��	����4��'r1c�(�	|j|d�Sr�rrrss  r/rmzSSLSocket.connect_exJs��	��!�!�$��-�-r1c���	t�|��\}}|jj||j|j
d��}||fS)NT)r<r=r;)r�acceptr?rCr<r=)r0�newsockr�rs   �r/rvzSSLSocket.acceptOsV���	>����(�
����,�,�*�*�7�,0�,H�,H�)-�)B�)B� $�+�&����}�r1c��|j�|jj|�S|tvrtdj	|���y)Nz({0} channel binding type not implemented)r�r��CHANNEL_BINDING_TYPESr�r�r�s  r/r�zSSLSocket.get_channel_binding[sJ���<�<�#��<�<�3�3�G�<�<��3�3� �>�E�E�g�N���r1c�P�|j�|jj�Syr�r�r�s r/r�zSSLSocket.versionfs"���<�<�#��<�<�'�'�)�)�r1)FTTNNNr�r�r�)r)rN)r�rrar�)/rErFrGr�rrBr�rr?r�r@r�r-r0r2r�r�r�r�r�r�r�r�r>r@rDrIrOrrWrYr[r]r_r�r�r�r�rir�rprnrmrvr�r�rrs@r/rr�s���;�
��FJ�;?�&*�\��\�|������
�^�^�#��#���(���(�
�^�^�+��+�
��/���/�;�
���*(��5��5�
�����9��9��)��)��1��1��.��.�	-�=�2�0� 9�	/�<�&3�@�2�9������
�C��C��C��C���%��%��4(�
.�

��������r1rc���	ddlm}ddlm}d}d}	|j	|ddj��dz}||dd|�}||d|f|dd	z�S#t$rt
d
|�d|�d���wxYw)
Nr)�strptime)�timegm)�Jan�Feb�Mar�Apr�May�Jun�Jul�Aug�Sep�Oct�Nov�Decz %d %H:%M:%S %Y GMTr�r�r�r�z
time data z does not match format "%b�")�timer|�calendarr}�index�titler�)�	cert_timer|r}�months�time_format�month_number�tts       r/�cert_time_to_secondsr�us�������F�(�K�
7��|�|�I�b�q�M�$7�$7�$9�:�Q�>���i���m�[�
1���r�!�u�l�+�b��1�g�5�6�6���F��-6��E�F�	F�F�s�%A�A3z-----BEGIN CERTIFICATE-----z-----END CERTIFICATE-----c��	ttj|�dd�}tg}|t	dt|�d�D�cgc]
}|||dz��c}z
}|j
tdz�dj|�Scc}w)N�ASCII�strictr�@�
)	r5�base64�standard_b64encode�
PEM_HEADER�rangerOrP�
PEM_FOOTER�join)�der_cert_bytes�f�ss�is    r/�DER_cert_to_PEM_certr��s��&�	�F�%�%�n�5�w��I�A�
��B��e�A�s�1�v�r�2�
3�2��1�Q�q��t�9�2�
3�3�B��I�I�j�4�� ��9�9�R�=���4s�A?c�b�	|jt�stdtz��|j�j	t
�stdt
z��|j�t
t�t
t
�}tj|jdd��S)Nz(Invalid PEM encoding; must start with %sz&Invalid PEM encoding; must end with %sr�r�)
r,r�r��strip�endswithr�rOr��decodebytesr6)�pem_cert_string�ds  r/�PEM_cert_to_DER_certr��s���4��%�%�j�1��C�%�&�'�	'�� � �"�+�+�J�7��A�%�&�'�	'������J���Z��0@�A�A����a�h�h�w��9�:�:r1c�(�	|\}}|�t}nt}t|||��}t||��5}|j	||��5}	|	jd�}
ddd�ddd�t

�S#1swY�xYw#1swYt

�SxYw)N)r�r)r&)r>T)r�r��_create_stdlib_contextr�rCr�r�)r��ssl_version�ca_certsr&�host�portr�r?r:�sslsock�dercerts           r/�get_server_certificater��s�����J�D�$���!�	��	�$�[�/8�,4�6�G�
�4��	1�T�
�
 �
 ��t�
 �
<���)�)�$�/�G�=�
2� ��(�(�=�
<��
2� ��(�(�s#�A>�A2�A>�2A;	�7A>�>Bc�.�tj|d�S)Nz	<unknown>)�_PROTOCOL_NAMESr)�
protocol_codes r/�get_protocol_namer��s�����}�k�:�:r1r�)lrsr�collectionsr�enumr�_Enumr�_IntEnumr�_IntFlagrrHrr	r
rrr
rrrrrrrrrrrrrrr�ImportErrorrrrrrr r!r"r#r$r%r&�	_convert_rEr'r,r*�__members__�itemsr�r��_SSLv2_IF_EXISTSrDrYrgr�rtr�r�r�r�r�r�r�r�r�r�rr)r��socket_errorryr��HAS_NEVER_CHECK_COMMON_NAME�_RESTRICTED_SERVER_CIPHERSr�r�r�r�r�rrrr#r r�r�r��_create_default_https_contextr�r�rrrArEr�r�r�r�r�r�r�r�)r.r�s00r/�<module>r�sa��X�t�	�"�H�H���N�N�3�3����:�2�2�	�����8������(�K���
����
�x�'���
������6���
�����h�.���
�����8�+���
�����(�)���
0:�/F�/F�F��*�,�2<�2H�2H�2N�2N�2P�Q�2P�;�4��5�$�;�2P�Q���:�'7��>���h��5�5��5��h�������h��&"�&"��&"�R�h�� � �� �:�<�<�7��1�9�9�?�?��
�����%���%�d�,J�K��.��+��.>�b D�F	� � 4����&�@�*�]�,H�I�@�*&�k�5�&�AG��AG�H$+�#6�#6�$�$�"&�t�$�L4�9�*/��9L�9L�$(�$�"&�t�D�4�n!7��4��X;�X;�v�|��|�@'�
��&�
��
7�<+�
�
(�
��;�.A�$(�2I�)�,;��g*�	��	��TRs�J%�=
J1�%J.�-J.

?>