AlkantarClanX12

Your IP : 18.118.162.8


Current Path : /proc/self/root/opt/alt/python311/lib64/python3.11/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python311/lib64/python3.11/__pycache__/ssl.cpython-311.opt-1.pyc

�

c��f!��
��dZddlZddlZddlmZddlmZmZ	m
ZddlmZddl
Z
ddl
mZmZmZddl
mZmZmZddl
mZmZmZmZmZmZmZdd	l
mZmZdd
l
mZm Z m!Z!m"Z"	ddl
m#Z#n#e$$rYnwxYwddl
m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.dd
l
m/Z/m0Z0e	j1de2d�e
���ej1de2d�e
���e	j1de2d�e
���e	j1de2d�e
���ej1de2d�e
���e	j1de2d�e
���e3j4xZ5e3_5d�e3j6�7��D��Z8e9e3dd��Z:ee	��Gd�d����Z;ee	��Gd�d ����Z<ee	��Gd!�d"����Z=ee	��Gd#�d$����Z>ej?d%krdd&l
m@Z@mAZAdd'lBmBZBmCZCmDZDdd(lBmEZEmFZFmGZGddlBZHddlIZIddlJZJddlKZKeLZMd)gZNeOe
d*��ZPe/ZQeZRd+�ZSd,�ZTd-�ZUd.�ZVed/d0��ZWd1�ZXGd2�d3ed3d4����ZYGd5�d6eYe��ZZGd7�d8e��Z[eZj\fdddd9�d:�Z]dLe^d;eZj\dddddd<�d=�Z_e]Z`e_ZaGd>�d?��Zbd@�ZcGdA�dBeB��Zdede[_eebe[_fddd;e^e4ddCdCdf	dD�ZgdE�ZhdFZidGZjdH�ZkdI�ZlemdeGfdJ�ZndK�ZodS)Ma�
This module provides some more Pythonic support for SSL.

Object types:

  SSLSocket -- subtype of socket.socket which does SSL over the socket

Exceptions:

  SSLError -- exception raised for I/O errors

Functions:

  cert_time_to_seconds -- convert time string used for certificate
                          notBefore and notAfter functions to integer
                          seconds past the Epoch (the time values
                          returned from time.time())

  get_server_certificate (addr, ssl_version, ca_certs, timeout) -- Retrieve the
                          certificate from the server at the specified
                          address and return it as a PEM-encoded string


Integer constants:

SSL_ERROR_ZERO_RETURN
SSL_ERROR_WANT_READ
SSL_ERROR_WANT_WRITE
SSL_ERROR_WANT_X509_LOOKUP
SSL_ERROR_SYSCALL
SSL_ERROR_SSL
SSL_ERROR_WANT_CONNECT

SSL_ERROR_EOF
SSL_ERROR_INVALID_ERROR_CODE

The following group define certificate requirements that one side is
allowing/requiring from the other side:

CERT_NONE - no certificates from the other side are required (or will
            be looked at if provided)
CERT_OPTIONAL - certificates are not required, but if provided will be
                validated, and if validation fails, the connection will
                also fail
CERT_REQUIRED - certificates are required, and will be validated, and
                if validation fails, the connection will also fail

The following constants identify various SSL protocol variants:

PROTOCOL_SSLv2
PROTOCOL_SSLv3
PROTOCOL_SSLv23
PROTOCOL_TLS
PROTOCOL_TLS_CLIENT
PROTOCOL_TLS_SERVER
PROTOCOL_TLSv1
PROTOCOL_TLSv1_1
PROTOCOL_TLSv1_2

The following constants identify various SSL alert message descriptions as per
http://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-6

ALERT_DESCRIPTION_CLOSE_NOTIFY
ALERT_DESCRIPTION_UNEXPECTED_MESSAGE
ALERT_DESCRIPTION_BAD_RECORD_MAC
ALERT_DESCRIPTION_RECORD_OVERFLOW
ALERT_DESCRIPTION_DECOMPRESSION_FAILURE
ALERT_DESCRIPTION_HANDSHAKE_FAILURE
ALERT_DESCRIPTION_BAD_CERTIFICATE
ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE
ALERT_DESCRIPTION_CERTIFICATE_REVOKED
ALERT_DESCRIPTION_CERTIFICATE_EXPIRED
ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN
ALERT_DESCRIPTION_ILLEGAL_PARAMETER
ALERT_DESCRIPTION_UNKNOWN_CA
ALERT_DESCRIPTION_ACCESS_DENIED
ALERT_DESCRIPTION_DECODE_ERROR
ALERT_DESCRIPTION_DECRYPT_ERROR
ALERT_DESCRIPTION_PROTOCOL_VERSION
ALERT_DESCRIPTION_INSUFFICIENT_SECURITY
ALERT_DESCRIPTION_INTERNAL_ERROR
ALERT_DESCRIPTION_USER_CANCELLED
ALERT_DESCRIPTION_NO_RENEGOTIATION
ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION
ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE
ALERT_DESCRIPTION_UNRECOGNIZED_NAME
ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE
ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE
ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY
�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_pseudo_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�8�|�d��o|dkS)N�	PROTOCOL_�PROTOCOL_SSLv23��
startswith��names �*/opt/alt/python311/lib64/python3.11/ssl.py�<lambda>r1}s������-�-�K�$�:K�2K��)�source�Optionsc�,�|�d��S)N�OP_r,r.s r0r1r1�s������'�'�r2�AlertDescriptionc�,�|�d��S)N�ALERT_DESCRIPTION_r,r.s r0r1r1�s�����!5�6�6�r2�SSLErrorNumberc�,�|�d��S)N�
SSL_ERROR_r,r.s r0r1r1�s������.�.�r2�VerifyFlagsc�,�|�d��S)N�VERIFY_r,r.s r0r1r1�s������+�+�r2�
VerifyModec�,�|�d��S)N�CERT_r,r.s r0r1r1�s������)�)�r2c��i|]\}}||��	S�rD)�.0r/�values   r0�
<dictcomp>rG�s��Q�Q�Q�;�4��5�$�Q�Q�Qr2�PROTOCOL_SSLv2c�p�eZdZejZejZejZ	ej
ZejZ
ejZejZdS)�
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_SUPPORTEDrDr2r0rJrJ�sJ�������4����E���E�� �G�� �G�� �G��4���r2rJc�*�eZdZdZdZdZdZdZdZdZ	dS)	�_TLSContentTypez@Content types (record layer)

    See RFC 8446, section B.1
    ������N)
rKrLrM�__doc__�CHANGE_CIPHER_SPEC�ALERT�	HANDSHAKE�APPLICATION_DATA�HEADER�INNER_CONTENT_TYPErDr2r0r^r^�s=�����������E��I���
�F����r2r^c��eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#d"Z$d#Z%d$S)%�
_TLSAlertTypezQAlert types for TLSContentType.ALERT messages

    See RFC 8466, section B.2
    r�
r_r`ra��(�)�*�+�,�-�.�/�0�1�2�3�<�F�G�P�V�Z�d�m�n�o�p�q�r�s�t�xN)&rKrLrMre�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_PROTOCOLrDr2r0rmrm�s����������L����N����O������N��O� �����������J��M��L��M��������N����M�������"����&)�#�!$������!���r2rmc�j�eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdS)�_TLSMessageTypezFMessage types (handshake protocol)

    See RFC 8446, section B.3
    r����������
���r_r`rarb��C�rdN)rKrLrMre�
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_HASHrfrDr2r0r�r��s����������M��L��L������������K������K������H��O������J��J��L����r2r��win32)�enum_certificates�	enum_crls)�socket�SOCK_STREAM�create_connection)�
SOL_SOCKET�SO_TYPE�_GLOBAL_DEFAULT_TIMEOUT�
tls-unique�HOSTFLAG_NEVER_CHECK_SUBJECTc��|sdS|�d��}|s*|���|���kS|dkr"td�|�����|�d��\}}}d|vr"td�|�����|s"td�|�����|dkr"td�|�����|�d��\}}}|r|sdS|���|���kS)	a�Matching according to RFC 6125, section 6.4.3

    - Hostnames are compared lower-case.
    - For IDNA, both dn and hostname must be encoded as IDN A-label (ACE).
    - Partial wildcards like 'www*.example.org', multiple wildcards, sole
      wildcard or wildcards in labels other then the left-most label are not
      supported and a CertificateError is raised.
    - A wildcard must match at least one character.
    F�*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        r0�_dnsname_matchr�sl�����u�����
�
�I��.��x�x�z�z�X�^�^�-�-�-�-��1�}�}��?�F�F�r�J�J�L�L�	L�&(�\�\�#�%6�%6�"�K��l�
�l����
��F�2�J�J� � �	 �� ��
��F�2�J�J� � �	 ��c����
��F�2�J�J� � �	 �2:�1C�1C�C�1H�1H�.��s�.���C���u������#5�#;�#;�#=�#=�=�=r2c��	tj|��}tj|��|kr|Std�|�����#t
$rYnwxYw	tjtj|��S#t
$r#td�|�����t$rYnwxYwtd�|�����)z�Try to convert an IP address to packed binary form

    Supports IPv4 addresses on all platforms and IPv6 on platforms with IPv6
    support.
    z'{!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  r0�_inet_patonr�Is	��
�� ��(�(��
��T�"�"�f�,�,��K��9�@�@��H�H���
���
�
�
���
����
�� ��!1�6�:�:�:���4�4�4��$�$*�F�6�N�N�4�4�	4��
�
�
���
�����3�:�:�6�B�B�
C�
C�Cs#�A�
A�A�#B�5B:�9B:c�P�t|�����}||kS)z�Exact matching of IP addresses.

    RFC 6125 explicitly doesn't define an algorithm for this
    (section 1.7.2 - "Out of Scope").
    )r��rstrip)�cert_ipaddress�host_ip�ips   r0�_ipaddress_matchrls'��
�^�*�*�,�,�	-�	-�B�
��=�r2c�^�tjdtd���|std���	t	|��}n#t$rd}YnwxYwg}|�dd��}|D]f\}}|dkr+|�t
||��rdS|�|���6|d	kr*|�t||��rdS|�|���g|sP|�d
d��D]9}|D]4\}}|dkr)t
||��rdS|�|���5�:t|��dkr;td
|�dd�tt|���������t|��dkrtd
|�d|d�����td���)a�Verify that *cert* (in decoded format as returned by
    SSLSocket.getpeercert()) matches the *hostname*.  RFC 2818 and RFC 6125
    rules are followed.

    The function matches IP addresses rather than dNSNames if hostname is a
    valid ipaddress string. IPv4 addresses are supported on all platforms.
    IPv6 addresses are supported on platforms with IPv6 support (AF_INET6
    and inet_pton).

    CertificateError is raised on failure. On success, the function
    returns nothing.
    z"ssl.match_hostname() is deprecatedr���category�
stacklevelztempty or no certificate, match_hostname needs a SSL socket or SSL context with either CERT_OPTIONAL or CERT_REQUIREDN�subjectAltNamerD�DNSz
IP Address�subject�
commonNamer�z	hostname z doesn't match either of z, z doesn't match rz=no appropriate commonName or subjectAltName fields were found)�warnings�warn�DeprecationWarningr�r��getr��appendr�lenr��join�map�repr)�certr�r�dnsnames�san�keyrF�subs        r0�match_hostnamerxs>��
�M�,�#������
�;��:�;�;�	;���h�'�'�����������������H�
�(�(�#�R�
(�
(�C��#�#�
��U��%�<�<���>�%��#B�#B������O�O�E�"�"�"�"�
�L�
 �
 ��"�'7��w�'G�'G�"�����O�O�E�"�"�"���
+��8�8�I�r�*�*�	+�	+�C�!�
+�
+�
��U��,�&�&�%�e�X�6�6�������O�O�E�*�*�*��

+��8�}�}�q������x�x����3�t�X�#6�#6�7�7�7� 9�:�:�	:�

�X���!�	�	����x�x��!��� &�'�'�	'�� /�0�0�	0s�?�A�
A�DefaultVerifyPathszQcafile capath openssl_cafile_env openssl_cafile openssl_capath_env openssl_capathc�x�tj��}tj�|d|d��}tj�|d|d��}ttj�|��r|ndtj�|��r|ndg|�R�S)z/Return paths to default cafile and capath.
    rr�r�r�N)	rN�get_default_verify_paths�os�environrr�path�isfile�isdir)�parts�cafile�capaths   r0rr�s���
�)�+�+�E��Z�^�^�E�!�H�e�A�h�
/�
/�F�
�Z�^�^�E�!�H�e�A�h�
/�
/�F������v�(>�(>�H�f�f�D�(*��
�
�f�(=�(=�G�f�f�4�&�$�&�&�&�&r2c�Z��eZdZdZdZ�fd�Ze�fd���Ze�fd���Z�xZ	S)�_ASN1Objectz#ASN.1 object identifier lookup
    rDc�V��t��j|gt|d����R�S)NFr.��super�__new__�_txt2obj)�cls�oid�	__class__s  �r0r*z_ASN1Object.__new__�s.����u�w�w��s�?�X�c��%>�%>�%>�?�?�?�?r2c�R��t��j|gt|���R�S)z3Create _ASN1Object from OpenSSL numeric ID
        )r)r*�_nid2obj)r,�nidr.s  �r0�fromnidz_ASN1Object.fromnid�s)����u�w�w��s�3�X�c�]�]�3�3�3�3r2c�V��t��j|gt|d����R�S)z=Create _ASN1Object from short name, long name or OID
        Tr.r()r,r/r.s  �r0�fromnamez_ASN1Object.fromname�s0����u�w�w��s�?�X�d��%>�%>�%>�?�?�?�?r2)
rKrLrMre�	__slots__r*�classmethodr2r4�
__classcell__�r.s@r0r&r&�s�����������I�@�@�@�@�@��4�4�4�4��[�4�
�@�@�@�@��[�@�@�@�@�@r2r&znid shortname longname oidc��eZdZdZdZdZdS)�PurposezDSSLContext purpose flags with X509v3 Extended Key Usage objects
    z1.3.6.1.5.5.7.3.1z1.3.6.1.5.5.7.3.2N)rKrLrMre�SERVER_AUTH�CLIENT_AUTHrDr2r0r:r:�s"��������%�K�%�K�K�Kr2r:c���eZdZdZdZdZdZd!d�Zd�Z				d"d�Z			d#d	�Z
d
�Zd�Zd�Z
d
�Zejfd�Zeed��r>e�fd���Zej�fd���Ze�fd���Zej�fd���Ze�fd���Zej�fd���Zeed��red���Zejd���Zned���Ze�fd���Zej�fd���Ze�fd���Ze�fd���Zej�fd���Ze�fd���Zej�fd ���Z�xZS)$�
SSLContextz|An SSLContext holds various SSL-related configuration options and
    data, such as certificates and possibly a private key.)�CA�ROOTNc�z�|�#tjdtd���t}t	j||��}|S)Nz9ssl.SSLContext() without protocol argument is deprecated.r�r)rrr
�PROTOCOL_TLSrr*)r,�protocol�args�kwargs�selfs     r0r*zSSLContext.__new__�sH�����M�K�+��
�
�
�
�
$�H��"�3��1�1���r2c��|�dSt|t��r(|�d���d��S|�d��S)N�idna�ascii)�
isinstance�str�encode�decode)rFr�s  r0�_encode_hostnamezSSLContext._encode_hostname�sQ�����4�
��#�
&�
&�	,��?�?�6�*�*�1�1�'�:�:�:��?�?�7�+�+�+r2FTc	�D�|j�|||||||���S)N)�sock�server_side�do_handshake_on_connect�suppress_ragged_eofs�server_hostname�context�session)�sslsocket_class�_create)rFrPrQrRrSrTrVs       r0�wrap_socketzSSLContext.wrap_socket�s9���#�+�+��#�$;�!5�+���,�
�
�	
r2c�h�|j�||||�|��||���S)N)rQrTrVrU)�sslobject_classrXrN)rF�incoming�outgoingrQrTrVs      r0�wrap_biozSSLContext.wrap_biosA���#�+�+��h�K� �1�1�/�B�B��T�,�
�
�	
r2c��tjdtd���t��}|D]~}t	|d��}t|��dkst|��dkrt
d���|�t|����|�|���|�	|��dS)N�'ssl NPN is deprecated, use ALPN insteadr��rrIr�z(NPN protocols must be 1 to 255 in length)
rrr
�	bytearray�bytesrrr�extend�_set_npn_protocols)rF�
npn_protocols�protosrC�bs     r0�set_npn_protocolszSSLContext.set_npn_protocolss����
�5���	
�	
�	
�	
�
����%�	�	�H��h��(�(�A��1�v�v��{�{�c�!�f�f�s�l�l��I�J�J�J��M�M�#�a�&�&�!�!�!��M�M�!���������'�'�'�'�'r2c�v�����	d�_dSt���std�����fd�}|�_dS)Nznot a callable objectc�H����|��}�|||��S�N)rN)�sslobj�
servername�sslctxrF�server_name_callbacks   ��r0�shim_cbz3SSLContext.set_servername_callback.<locals>.shim_cb0s+���!�2�2�:�>�>�
�+�+�F�J��G�G�Gr2)�sni_callback�callable�	TypeError)rFrqrrs`` r0�set_servername_callbackz"SSLContext.set_servername_callback)sl�����'� $�D�����0�1�1�
9�� 7�8�8�8�
H�
H�
H�
H�
H�
H�!(�D���r2c�N�t��}|D]~}t|d��}t|��dkst|��dkrtd���|�t|����|�|���|�|��dS)NrIrrbz)ALPN protocols must be 1 to 255 in length)rcrdrrrre�_set_alpn_protocols)rF�alpn_protocolsrhrCris     r0�set_alpn_protocolszSSLContext.set_alpn_protocols6s�������&�	�	�H��h��(�(�A��1�v�v��{�{�c�!�f�f�s�l�l��J�K�K�K��M�M�#�a�&�&�!�!�!��M�M�!������ � ��(�(�(�(�(r2c��t��}	t|��D].\}}}|dkr"|dus	|j|vr|�|���/n$#t$rtjd��YnwxYw|r|�|���|S)N�x509_asnTz-unable to enumerate Windows certificate store)�cadata)rcr�r-re�PermissionErrorrr�load_verify_locations)rF�	storename�purpose�certsr�encoding�trusts       r0�_load_windows_store_certsz$SSLContext._load_windows_store_certsAs�������	K�):�9�)E�)E�
+�
+�%��h���z�)�)���}�}���u�(<�(<����T�*�*�*��	
+��
�	K�	K�	K��M�I�J�J�J�J�J�	K�����	5��&�&�e�&�4�4�4��s�>A�A0�/A0c���t|t��st|���tjdkr |jD]}|�||���|���dS)Nr�)rJr&ru�sys�platform�_windows_cert_storesr��set_default_verify_paths)rFr�r�s   r0�load_default_certszSSLContext.load_default_certsOst���'�;�/�/�	%��G�$�$�$��<�7�"�"�!�6�
C�
C�	��.�.�y�'�B�B�B�B��%�%�'�'�'�'�'r2�minimum_versionc�D��tt��j��Srm)rJr)r��rFr.s �r0r�zSSLContext.minimum_versionX�����e�g�g�5�6�6�6r2c����|tjkr|xjtjzc_ttt��j�||��dSrm)	rJrR�optionsr4�OP_NO_SSLv3r)r>r��__set__�rFrFr.s  �r0r�zSSLContext.minimum_version\sP����
�(�(�(�����!4� 4�4����*�j�)�)�9�A�A�$��N�N�N�N�Nr2c�D��tt��j��Srm)rJr)�maximum_versionr�s �r0r�zSSLContext.maximum_versionbr�r2c�n��ttt��j�||��dSrm)r)r>r�r�r�s  �r0r�zSSLContext.maximum_versionfs,����*�j�)�)�9�A�A�$��N�N�N�N�Nr2c�D��tt��j��Srm)r4r)r�r�s �r0r�zSSLContext.optionsjs����u�w�w��'�'�'r2c�n��ttt��j�||��dSrm)r)r>r�r�r�s  �r0r�zSSLContext.optionsns,���
�j�*�%�%�-�5�5�d�E�B�B�B�B�Br2r�c�J�|jtjz}|tjkSrm��_host_flagsrNr�)rF�ncss  r0�hostname_checks_common_namez&SSLContext.hostname_checks_common_namess ���"�T�%F�F�C��$�;�;�;r2c�x�|r|xjtjzc_dS|xjtjzc_dSrmr�)rFrFs  r0r�z&SSLContext.hostname_checks_common_namexsH���
F�� � �T�%F�$F�F� � � � �� � �D�$E�E� � � � r2c��dS)NTrD�rFs r0r�z&SSLContext.hostname_checks_common_names���4r2c�@��t��j}|�|jSdS)a9TLS message callback

        The message callback provides a debugging hook to analyze TLS
        connections. The callback is called for any TLS protocol message
        (header, handshake, alert, and more), but not for application data.
        Due to technical  limitations, the callback can't be used to filter
        traffic or to abort a connection. Any exception raised in the
        callback is delayed until the handshake, read, or write operation
        has been performed.

        def msg_cb(conn, direction, version, content_type, msg_type, data):
            pass

        conn
            :class:`SSLSocket` or :class:`SSLObject` instance
        direction
            ``read`` or ``write``
        version
            :class:`TLSVersion` enum member or int for unknown version. For a
            frame header, it's the header version.
        content_type
            :class:`_TLSContentType` enum member or int for unsupported
            content type.
        msg_type
            Either a :class:`_TLSContentType` enum number for a header
            message, a :class:`_TLSAlertType` enum member for an alert
            message, a :class:`_TLSMessageType` enum member for other
            messages, or int for unsupported message types.
        data
            Raw, decrypted message content as bytes
        N)r)�
_msg_callback�
user_function)rF�innerr.s  �r0r�zSSLContext._msg_callback�s&���B���%�����&�&��4r2c�:�����5ttt��j�|d��dSt	�d��st��d�����fd�}�|_ttt��j�||��dS)N�__call__z is not callable.c�P��	t|��}n#t$rYnwxYw	t|��}n#t$rYnwxYw|tjkrt}n|tjkrt
}nt}	||��}n#t$rYnwxYw�||||||��Srm)rJr�r^rjrgrmr�)�conn�	direction�version�content_type�msg_type�data�msg_enum�callbacks       �r0r�z'SSLContext._msg_callback.<locals>.inner�s����
�$�W�-�-�����
�
�
���
����
�.�|�<�<�����
�
�
���
������5�5�5�*�����!6�6�6�(���*��
�#�8�H�-�-�����
�
�
���
�����8�D�)�W�(�(�D�:�:�
:s-��
 � �4�
A�A�<B�
B�B)r)r>r�r��hasattrrur�)rFr�r�r.s ` �r0r�zSSLContext._msg_callback�s��������*�j�)�)�7�?�?��d�K�K�K��F��x��,�,�	<��x�:�:�:�;�;�;�	:�	:�	:�	:�	:�2'���
�j�*�%�%�3�;�;�D�%�H�H�H�H�Hr2c�D��tt��j��Srm)r(r)rCr�s �r0rCzSSLContext.protocol�s����%�'�'�*�+�+�+r2c�D��tt��j��Srm)r=r)�verify_flagsr�s �r0r�zSSLContext.verify_flags�s����5�7�7�/�0�0�0r2c�n��ttt��j�||��dSrm)r)r>r�r�r�s  �r0r�zSSLContext.verify_flags�s,���
�j�*�%�%�2�:�:�4��G�G�G�G�Gr2c�n��t��j}	t|��S#t$r|cYSwxYwrm)r)�verify_moder@r�r�s  �r0r�zSSLContext.verify_mode�sF������#��	��e�$�$�$���	�	�	��L�L�L�	���s�%�4�4c�n��ttt��j�||��dSrm)r)r>r�r�r�s  �r0r�zSSLContext.verify_mode�s,���
�j�*�%�%�1�9�9�$��F�F�F�F�Fr2rm)FTTNN)FNN) rKrLrMrer�rWr[r*rNrYr^rjrvrzr�r:r;r�r�r�propertyr��setterr�r�rNr�r�rCr�r�r7r8s@r0r>r>�s��������>�>�)���O��O�	�	�	�	�,�,�,�-2�,0�)-�26�
�
�
�
� 8=�/3�
�
�
�
�(�(�(� (�(�(�	)�	)�	)����*1�)<�(�(�(�(��w�{�-�.�.�O�	�	7�	7�	7�	7�
��	7�
�	�	O�	O�	O�	O�
 �	�	O�

�	7�	7�	7�	7�
��	7�
�	�	O�	O�	O�	O�
 �	�	O��(�(�(�(��X�(�
�^�C�C�C�C��^�C��w�t�3�4�4��	�	<�	<�
��	<�
%�	+�	F�	F�
,�	+�	F�	F�
�	�	�
��	��$�$�$�$��X�$�L��#I�#I�#I�#I���#I�J�,�,�,�,��X�,��1�1�1�1��X�1���H�H�H�H���H�������X����G�G�G�G���G�G�G�G�Gr2r>)r#r$r}c�>�t|t��st|���|tjkr(tt��}t|_d|_	n4|tj
krtt��}nt|���|s|s|r|�
|||��n%|jtkr|�|��t!|d��r9t"j�d��}|rt(jjs||_|S)z�Create a SSLContext object with default settings.

    NOTE: The protocol and settings may change anytime without prior
          deprecation. The values represent a fair balance between maximum
          compatibility and security.
    T�keylog_filename�
SSLKEYLOGFILE)rJr&rur:r;r>�PROTOCOL_TLS_CLIENT�
CERT_REQUIREDr��check_hostnamer<�PROTOCOL_TLS_SERVERr�r�	CERT_NONEr�r�rrrr��flags�ignore_environmentr�)r�r#r$r}rU�
keylogfiles      r0�create_default_contextr��s���g�{�+�+�!��� � � �
�'�%�%�%��0�1�1��+���!%����	�G�'�	'�	'��0�1�1�����!�!�!�
�,��,�6�,��%�%�f�f�f�=�=�=�=�	�	�	�	)�	)�	�"�"�7�+�+�+��w�)�*�*�1��Z�^�^�O�4�4�
��	1�c�i�:�	1�&0�G�#��Nr2F)�	cert_reqsr�r��certfile�keyfiler#r$r}c��t|t��st|���|tjkr
|�t
}n)|tjkr
|�t}nt|���t|��}	||	_
|�||	_|rd|	_
|r|std���|s|r|	�||��|s|s|r|	�
|||��n%|	jtkr|	�|��t!|	d��r9t"j�d��}
|
rt(jjs|
|	_|	S)a/Create a SSLContext object for Python stdlib modules

    All Python stdlib modules shall use this function to create SSLContext
    objects in order to keep common settings in one place. The configuration
    is less restrict than create_default_context()'s to increase backward
    compatibility.
    NT�certfile must be specifiedr�r�)rJr&rur:r;r�r<r�r�r>r�r��load_cert_chainrr�r�r�rrrr�r�r�r�)rCr�r�r�r�r�r#r$r}rUr�s           r0�_create_unverified_contextr�s|���g�{�+�+�!��� � � �
�'�%�%�%���*�H��	�G�'�	'�	'���*�H����!�!�!���"�"�G�+�G����'����&�!%����7�x�7��5�6�6�6��3�7�3�����'�2�2�2��,��,�6�,��%�%�f�f�f�=�=�=�=�	�	�	�	)�	)�	�"�"�7�+�+�+��w�)�*�*�1��Z�^�^�O�4�4�
��	1�c�i�:�	1�&0�G�#��Nr2c�<�eZdZdZd�Ze		dd���Zed���Zej	d���Zed���Z
e
j	d	���Z
ed
���Zed���Zed���Z
dd�Zd�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd d�Zd�Zd�ZdS)!�	SSLObjectaThis class implements an interface on top of a low-level SSL object as
    implemented by OpenSSL. This object captures the state of an SSL connection
    but does not provide any network IO itself. IO needs to be performed
    through separate "BIO" objects which are OpenSSL's IO abstraction layer.

    This class does not have a public constructor. Instances are returned by
    ``SSLContext.wrap_bio``. This class is typically used by framework authors
    that want to implement asynchronous IO for SSL through memory buffers.

    When compared to ``SSLSocket``, this object lacks the following features:

     * Any form of network IO, including methods such as ``recv`` and ``send``.
     * The ``do_handshake_on_connect`` and ``suppress_ragged_eofs`` machinery.
    c�:�t|jj�d����)NzU does not have a public constructor. Instances are returned by SSLContext.wrap_bio().�rur.rK�rFrDrEs   r0�__init__zSSLObject.__init__\s.����~�&�
M�
M�
M�
�
�	
r2FNc�t�|�|��}|�||||||���}||_|S)N)rQrT�ownerrV)r*�	_wrap_bio�_sslobj)	r,r\r]rQrTrVrUrFrns	         r0rXzSSLObject._createbsL���{�{�3�����"�"��h�K�+���#�
�
��
����r2c��|jjS)z(The SSLContext that is currently in use.�r�rUr�s r0rUzSSLObject.contextn����|�#�#r2c��||j_dSrmr��rF�ctxs  r0rUzSSLObject.contextss��"�����r2c��|jjS)z!The SSLSession for client socket.�r�rVr�s r0rVzSSLObject.sessionwr�r2c��||j_dSrmr��rFrVs  r0rVzSSLObject.session|s��&�����r2c��|jjS)z.Was the client session reused during handshake�r��session_reusedr�s r0r�zSSLObject.session_reused�s���|�*�*r2c��|jjS)z%Whether this is a server-side socket.)r�rQr�s r0rQzSSLObject.server_side�s���|�'�'r2c��|jjS)z^The currently set server hostname (for SNI), or ``None`` if no
        server hostname is set.)r�rTr�s r0rTzSSLObject.server_hostname�s���|�+�+r2�c�v�|�|j�||��}n|j�|��}|S)z�Read up to 'len' bytes from the SSL object and return them.

        If 'buffer' is provided, read into this buffer and return the number of
        bytes read.
        )r��read)rFr�buffer�vs    r0r�zSSLObject.read�s=������!�!�#�v�.�.�A�A���!�!�#�&�&�A��r2c�6�|j�|��S)z�Write 'data' to the SSL object and return the number of bytes
        written.

        The 'data' argument must support the buffer interface.
        )r��write�rFr�s  r0r�zSSLObject.write�s���|�!�!�$�'�'�'r2c�6�|j�|��S)z�Returns a formatted version of the data in the certificate provided
        by the other end of the SSL channel.

        Return None if no certificate was provided, {} if a certificate was
        provided, but not validated.
        )r��getpeercert�rF�binary_forms  r0r�zSSLObject.getpeercert�s���|�'�'��4�4�4r2c�>�tjdtd���dS)z�Return the currently selected NPN protocol as a string, or ``None``
        if a next protocol was not negotiated or if NPN is not supported by one
        of the peers.r`r�raN)rrr
r�s r0�selected_npn_protocolzSSLObject.selected_npn_protocol�s0��	�
�5���	
�	
�	
�	
�	
�	
r2c�4�|j���S)z�Return the currently selected ALPN protocol as a string, or ``None``
        if a next protocol was not negotiated or if ALPN is not supported by one
        of the peers.)r��selected_alpn_protocolr�s r0r�z SSLObject.selected_alpn_protocol�s���|�2�2�4�4�4r2c�4�|j���S)z_Return the currently selected cipher as a 3-tuple ``(name,
        ssl_version, secret_bits)``.)r��cipherr�s r0r�zSSLObject.cipher�s���|�"�"�$�$�$r2c�4�|j���S)z�Return a list of ciphers shared by the client during the handshake or
        None if this is not a valid server connection.
        )r��shared_ciphersr�s r0r�zSSLObject.shared_ciphers�s���|�*�*�,�,�,r2c�4�|j���S)z�Return the current compression algorithm in use, or ``None`` if
        compression was not negotiated or not supported by one of the peers.)r��compressionr�s r0r�zSSLObject.compression�s���|�'�'�)�)�)r2c�4�|j���S)z8Return the number of bytes that can be read immediately.)r��pendingr�s r0r�zSSLObject.pending�s���|�#�#�%�%�%r2c�8�|j���dS)zStart the SSL/TLS handshake.N)r��do_handshaker�s r0rzSSLObject.do_handshake�s����!�!�#�#�#�#�#r2c�4�|j���S)z!Start the SSL shutdown handshake.)r��shutdownr�s r0�unwrapzSSLObject.unwrap�s���|�$�$�&�&�&r2r�c�6�|j�|��S)z�Get channel binding data for current connection.  Raise ValueError
        if the requested `cb_type` is not supported.  Return bytes of the data
        or None if the data is not available (e.g. before the handshake).)r��get_channel_binding�rF�cb_types  r0rzSSLObject.get_channel_binding�s���|�/�/��8�8�8r2c�4�|j���S)zZReturn a string identifying the protocol version used by the
        current SSL channel. �r�r�r�s r0r�zSSLObject.version�s���|�#�#�%�%�%r2c�4�|j���Srm)r��verify_client_post_handshaker�s r0rz&SSLObject.verify_client_post_handshake�s���|�8�8�:�:�:r2)FNNN�r�N�F�r�)rKrLrMrer�r6rXr�rUr�rVr�rQrTr�r�r�r�r�r�r�r�r�rrrr�rrDr2r0r�r�Ms�������
�
�
�
�
��5:�=A�	�	�	��[�	��$�$��X�$�
�^�#�#��^�#��$�$��X�$�
�^�'�'��^�'��+�+��X�+��(�(��X�(��,�,��X�,�

�
�
�
�(�(�(�5�5�5�5�
�
�
�5�5�5�%�%�%�
-�-�-�*�*�*�
&�&�&�$�$�$�'�'�'�9�9�9�9�&�&�&�
;�;�;�;�;r2r�c�N�tt|j��j|_|S)z*Copy docstring from SSLObject to SSLSocket)�getattrr�rKre)�funcs r0�_sslcopydocr�s���9�d�m�4�4�<�D�L��Kr2c����eZdZdZd�Ze			d1�fd�	��Zeed�����Z	e	j
d���Z	eed	�����Zej
d
���Zeed�����Zd�Z
d2d
�Zd�Zd3d�Zd�Zed4d���Zed���Zed���Zed���Zed���Zed���Zd5�fd�	Zd2�fd�	Zd�Zd5�fd�	Zd6�fd�	Zd7�fd�	Zd8�fd�	Zd7�fd �	Zd8�fd!�	Z d"�Z!d#�Z"ed$���Z#�fd%�Z$ed&���Z%ed'���Z&�fd(�Z'ed4d)���Z(�fd*�Z)d+�Z*d,�Z+�fd-�Z,ed9d/���Z-ed0���Z.�xZ/S):�	SSLSocketz�This class implements a subtype of socket.socket that wraps
    the underlying OS socket in an SSL context when necessary, and
    provides read and write methods over that channel. c�:�t|jj�d����)NzX does not have a public constructor. Instances are returned by SSLContext.wrap_socket().r�r�s   r0r�zSSLSocket.__init__�s+����~�&�
)�
)�
)�
�
�	
r2FTNc���|�tt��tkrt	d���|r"|rtd���|�td���|jr|std���|���}t|j	|j
|j|������}	|j
|fi|	��}
tt|
��jdi|	��|���	||
_||
_d|
_d|
_||
_|�|��|
_||
_||
_	|
���d}n�#t8$r�}|jt:jkr�d}|
���}
|
� d��	|
�!d��}n9#t8$r,}|jt:jt:j"fvr�d	}Yd}~nd}~wwxYw|
� |
��|r/d
}tG|j|��}||_$d|_%	|�#d}wxYwYd}~nd}~wwxYw|
�&|��||
_'|rm|
j�(|
||
j|
|
j���|
_|r=|
���}|dkrtd
���|
�)��n,#	|
�*��n#t8$rYnwxYw�xYw|
S)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�r2z5Closed before TLS handshake with data in recv buffer.�r�rV�zHdo_handshake_on_connect should not be specified for non-blocking socketsrD)+�
getsockoptr�r�r��NotImplementedErrorr�r��
gettimeout�dictrrrrr*r)rr��detach�_context�_session�_closedr�rQrNrTrRrS�getpeernamer��errno�ENOTCONN�getblocking�setblocking�recv�EINVALr�reason�library�
settimeout�
_connected�_wrap_socketr�close)r,rPrQrRrSrTrUrV�sock_timeoutrErF�	connected�e�blocking�notconn_pre_handshake_datar,� notconn_pre_handshake_data_error�timeoutr.s                  �r0rXzSSLSocket._create�s�����?�?�:�w�/�/�;�>�>�%�&I�J�J�J��	0��
3� �"2�3�3�3��"� �"/�0�0�0��!�	H�/�	H��F�G�G�G����(�(����;�T�Y�d�j��;�;�=�=�
�
�
���s�{�3�)�)�&�)�)��'��i����'�1�1�&�1�1�1����
�
�
�C	�#�D�M�#�D�M� �D�L��D�L�*�D��#*�#;�#;�O�#L�#L�D� �+B�D�(�(<�D�%�#
!�� � �"�"�"�D!�	�	��C�
@�
@�
@��7�e�n�,�,��!�	��+�+�-�-��� � ��'�'�'�
5�
26���1���.�.���5�5�5��w�u�~�u�|�&D�D�D��14�.�.�.�.�.�.�����	5����
� � ��*�*�*�-�
@�U�F�7?����7P�7P�4�>D�4�;�?C�4�<�@�>�>��<@�8�?�?�?�?�
@�
@�
@�
@�
@�����%
@����F
�O�O�L�)�)�)�'�D�O��
(�#�}�9�9��+�t�';���
� :� � ���+�(�"�o�o�/�/�G��#�~�~�(�)s�t�t�t��%�%�'�'�'���	�
��
�
�������
�
�
���
���������s��AK�
E$�!K�$
I�.AI
�0G�I
�
G<�"G7�2I
�7G<�<?I
�<H>�>I�I
�K�
I�BK�L�!K6�5L�6
L�L�L�Lc��|jSrm)r"r�s r0rUzSSLSocket.contextYs���}�r2c�,�||_||j_dSrm)r"r�rUr�s  r0rUzSSLSocket.context^s����
�"�����r2c�,�|j�|jjSdSrmr�r�s r0rVzSSLSocket.sessioncs���<�#��<�'�'�$�#r2c�>�||_|j�||j_dSdSrm)r#r�rVr�s  r0rVzSSLSocket.sessionis)����
��<�#�#*�D�L� � � �$�#r2c�,�|j�|jjSdSrmr�r�s r0r�zSSLSocket.session_reusedos���<�#��<�.�.�$�#r2c�:�td|jjz���)NzCan't dup() %s instances)rr.rKr�s r0�dupz
SSLSocket.dupus$��!�"<�"&�.�"9�#:�;�;�	;r2c��dSrmrD)rF�msgs  r0�_checkClosedzSSLSocket._checkClosedys���r2c�@�|js|���dSdSrm)r/r%r�s r0�_check_connectedzSSLSocket._check_connected}s0����	�

��������	�	r2r�c�B�|���|j�td���	|�|j�||��S|j�|��S#t$r1}|jdtkr|jr|�Yd}~dSYd}~dS�d}~wwxYw)zORead up to LEN bytes and return them.
        Return zero-length string on EOF.Nz'Read on closed or unwrapped SSL socket.rr2)rBr�r�r�rrD�
SSL_ERROR_EOFrS)rFrr��xs    r0r�zSSLSocket.read�s���	
�������<���F�G�G�G�	��!��|�(�(��f�5�5�5��|�(�(��-�-�-���	�	�	��v�a�y�M�)�)�d�.G�)��%��1�1�1�1�1��3�3�3�3�3������	���s#�A#�	A#�#
B�-B�B�Bc��|���|j�td���|j�|��S)zhWrite DATA to the underlying SSL channel.  Returns
        number of bytes of DATA actually transmitted.Nz(Write on closed or unwrapped SSL socket.)rBr�r�r�r�s  r0r�zSSLSocket.write�sC��	
�������<���G�H�H�H��|�!�!�$�'�'�'r2c��|���|���|j�|��Srm)rBrDr�r�r�s  r0r�zSSLSocket.getpeercert�s<���������������|�'�'��4�4�4r2c�f�|���tjdtd���dS)Nr`r�ra)rBrrr
r�s r0r�zSSLSocket.selected_npn_protocol�s=���������
�5���	
�	
�	
�	
�
�tr2c��|���|j�tjsdS|j���Srm)rBr�rNrr�r�s r0r�z SSLSocket.selected_alpn_protocol�s<���������<��t�}���4��<�6�6�8�8�8r2c�n�|���|j�dS|j���Srm)rBr�r�r�s r0r�zSSLSocket.cipher�s5���������<���4��<�&�&�(�(�(r2c�n�|���|j�dS|j���Srm)rBr�r�r�s r0r�zSSLSocket.shared_ciphers�s5���������<���4��<�.�.�0�0�0r2c�n�|���|j�dS|j���Srm)rBr�r�r�s r0r�zSSLSocket.compression�s5���������<���4��<�+�+�-�-�-r2rc����|���|j�7|dkrtd|jz���|j�|��St���||��S)Nrz3non-zero flags not allowed in calls to send() on %s)rBr�r�r.r�r)�send)rFr�r�r.s   �r0rPzSSLSocket.send�su����������<�#���z�z� �I��N�#�$�$�$��<�%�%�d�+�+�+��7�7�<�<��e�,�,�,r2c���|���|j�td|jz���|�"t	���||��St	���|||��S)Nz%sendto not allowed on instances of %s)rBr�r�r.r)�sendto)rFr��
flags_or_addrr�r.s    �r0rRzSSLSocket.sendto�ss����������<�#��D�!�^�,�-�-�
-�
�\��7�7�>�>�$�
�6�6�6��7�7�>�>�$�
�t�<�<�<r2c�0�td|jz���)Nz&sendmsg not allowed on instances of %s�rr.r�s   r0�sendmsgzSSLSocket.sendmsg�s#��"�"J�"&�.�#1�2�2�	2r2c����|���|j��|dkrtd|jz���d}t	|��5}|�d��5}t
|��}||kr(|�||d���}||z
}||k�(ddd��n#1swxYwYddd��dS#1swxYwYdSt���	||��S)Nrz6non-zero flags not allowed in calls to sendall() on %s�B)
rBr�r�r.�
memoryview�castrrPr)�sendall)	rFr�r�r��view�	byte_view�amountr�r.s	        �r0r[zSSLSocket.sendall�sx����������<�#���z�z� �L��N�#�$�$�$��E��D�!�!�
�T�4�9�9�S�>�>�
�Y��Y�����f�n�n��	�	�)�E�F�F�"3�4�4�A��Q�J�E��f�n�n�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
�
��7�7�?�?�4��/�/�/s6�C�!>B+�C�+B/	�/C�2B/	�3C�C�
Cc���|j�|�|||��St���|||��S)z�Send a file, possibly by using os.sendfile() if this is a
        clear-text socket.  Return the total number of bytes sent.
        )r��_sendfile_use_sendr)�sendfile)rF�file�offsetr�r.s    �r0razSSLSocket.sendfile�sC����<�#��*�*�4���?�?�?��7�7�#�#�D�&�%�8�8�8r2c����|���|j�2|dkrtd|jz���|�|��St���||��S)Nrz3non-zero flags not allowed in calls to recv() on %s)rBr�r�r.r�r)r*�rF�buflenr�r.s   �r0r*zSSLSocket.recvsq����������<�#���z�z� �I��N�#�$�$�$��9�9�V�$�$�$��7�7�<�<���.�.�.r2c�X��|���|�7|�3t|��5}|j}ddd��n#1swxYwY|sd}nd}|j�3|dkrt	d|jz���|�||��St���|||��S)Nr�rz8non-zero flags not allowed in calls to recv_into() on %s)	rBrY�nbytesr�r�r.r�r)�	recv_into)rFr�rhr�r\r.s     �r0rizSSLSocket.recv_intos�����������>��!���'�'�)�4�!�[�F�)�)�)�)�)�)�)�)�)�)�)����)�)�)�)��"�!�F�����<�#���z�z� �L��.�!�"�"�"��9�9�V�V�,�,�,��7�7�$�$�V�V�U�;�;�;s�=�A�Ac���|���|j�td|jz���t	���||��S)Nz'recvfrom not allowed on instances of %s)rBr�r�r.r)�recvfromres   �r0rkzSSLSocket.recvfrom&sX����������<�#��F�!�^�,�-�-�
-��7�7�#�#�F�E�2�2�2r2c���|���|j�td|jz���t	���|||��S)Nz,recvfrom_into not allowed on instances of %s)rBr�r�r.r)�
recvfrom_into)rFr�rhr�r.s    �r0rmzSSLSocket.recvfrom_into.sZ����������<�#��K�!�^�,�-�-�
-��7�7�(�(����?�?�?r2c�0�td|jz���)Nz&recvmsg not allowed on instances of %srUr�s   r0�recvmsgzSSLSocket.recvmsg6s!��!�"J�"&�.�#1�2�2�	2r2c�0�td|jz���)Nz+recvmsg_into not allowed on instances of %srUr�s   r0�recvmsg_intozSSLSocket.recvmsg_into:s#��!�#'�)-��#8�9�9�	9r2c�n�|���|j�|j���SdS�Nr)rBr�r�r�s r0r�zSSLSocket.pending>s5���������<�#��<�'�'�)�)�)��1r2c���|���d|_t���|��dSrm)rBr�r)r)rF�howr.s  �r0rzSSLSocket.shutdownFs:������������
����������r2c��|jr"|j���}d|_|Stdt|��z����NzNo SSL wrapper around )r�rr�rK)rF�ss  r0rzSSLSocket.unwrapKsF���<�	C���%�%�'�'�A��D�L��H��5��D�	�	�A�B�B�Br2c��|jr|j���Stdt|��z���rw)r�rr�rKr�s r0rz&SSLSocket.verify_client_post_handshakeTs;���<�	C��<�<�<�>�>�>��5��D�	�	�A�B�B�Br2c�V��d|_t�����dSrm)r�r)�_real_closer�s �r0r{zSSLSocket._real_close[s&������
���������r2c�"�|���|���}	|dkr|r|�d��|j���|�|��dS#|�|��wxYw)Nr)rDrr.r�r)rF�blockr8s   r0rzSSLSocket.do_handshake_s����������/�/�#�#��	%��#�~�~�%�~�����%�%�%��L�%�%�'�'�'��O�O�G�$�$�$�$�$��D�O�O�G�$�$�$�$���s�6A7�7Bc����|jrtd���|js|j�td���|j�|d|j||j���|_	|r"t���	|��}n#d}t���
|��|s"d|_|jr|���|S#ttf$r	d|_�wxYw)Nz!can't connect in server-side modez/attempt to connect already-connected SSLSocket!FrT)rQr�r/r�rUr0rTr#r)�
connect_ex�connectrRrr�)rFr�r�rcr.s    �r0�
_real_connectzSSLSocket._real_connectjs�����	B��@�A�A�A��?�	P�d�l�6��N�O�O�O��|�0�0��%��-���
�1�
�
���
	��
&��W�W�'�'��-�-�����������%�%�%��
(�"&����/�(��%�%�'�'�'��I����$�	�	�	��D�L��	���s
�$A,C�C+c�2�|�|d��dS)�QConnects to remote ADDR, and then wraps the connection in
        an SSL channel.FN�r��rFr�s  r0r�zSSLSocket.connect�s ��	
���4��'�'�'�'�'r2c�.�|�|d��S)r�Tr�r�s  r0rzSSLSocket.connect_ex�s���!�!�$��-�-�-r2c���t�����\}}|j�||j|jd���}||fS)z�Accepts a new connection from a remote client, and returns
        a tuple containing that new connection wrapped with a server-side
        SSL channel, and the address of the remote client.T)rRrSrQ)r)�acceptrUrYrRrS)rF�newsockr�r.s   �r0r�zSSLSocket.accept�sU���
�����(�(�
����,�*�*�7�,0�,H�)-�)B� $�+�&�&����}�r2r�c��|j�|j�|��S|tvr"td�|�����dS)Nz({0} channel binding type not implemented)r�r�CHANNEL_BINDING_TYPESr�r�rs  r0rzSSLSocket.get_channel_binding�sV���<�#��<�3�3�G�<�<�<��3�3�3� �>�E�E�g�N�N�����4r2c�F�|j�|j���SdSrmr	r�s r0r�zSSLSocket.version�s#���<�#��<�'�'�)�)�)��4r2)FTTNNNrmrr
)r)rN)r�rrsr)0rKrLrMrer�r6rXr�rrUr�rVr�r?rBrDr�r�r�r�r�r�r�r�rPrRrVr[rar*rirkrmrorqr�rrrr{rr�r�rr�rr�r7r8s@r0rr�sn�������;�;�
�
�
��FJ�;?�&*�\�\�\�\�\��[�\�|�����[��X��
�^�#�#��^�#���(�(��[��X�(�
�^�+�+��^�+�
��/�/��[��X�/�;�;�;�
�
�
�
��������*(�(�(��5�5�5��[�5�
����[���9�9��[�9��)�)��[�)��1�1��[�1��.�.��[�.�	-�	-�	-�	-�	-�	-�=�=�=�=�=�=�2�2�2�0�0�0�0�0�0� 9�9�9�9�9�9�	/�	/�	/�	/�	/�	/�<�<�<�<�<�<�&3�3�3�3�3�3�@�@�@�@�@�@�2�2�2�9�9�9�����[�������
�C�C��[�C��C�C��[�C�������%�%�%��[�%������4(�(�(�
.�.�.�

�
�
�
�
������[������[�����r2rTc
�p�tjdtd���|r|std���|r|std���t	|��}
||
_|r|
�|��|r|
�||��|	r|
�|	��|
�	||||���S)Nz=ssl.wrap_socket() is deprecated, use SSLContext.wrap_socket()r�rz5certfile must be specified for server-side operationsr�)rPrQrRrS)
rrr
r�r>r�rr��set_ciphersrY)rPr�r�rQr��ssl_version�ca_certsrRrS�ciphersrUs           r0rYrY�s���
�M�G�#������
�'�8�'��&�'�'�	'��7�x�7��5�6�6�6���%�%�G�#�G���0��%�%�h�/�/�/��3�����'�2�2�2��%����G�$�$�$����
�{� 7�1����r2c�4�ddlm}ddlm}d}d}	|�|dd������dz}||dd�|��}||d|f|d	d
�z��S#t$rt
d|�d|�d
����wxYw)a�Return the time in seconds since the Epoch, given the timestring
    representing the "notBefore" or "notAfter" date from a certificate
    in ``"%b %d %H:%M:%S %Y %Z"`` strptime format (C locale).

    "notBefore" or "notAfter" dates must use UTC (RFC 5280).

    Month is one of: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
    UTC should be specified as GMT (see ASN1_TIME_print())
    r)�strptime)�timegm)�Jan�Feb�Mar�Apr�May�Jun�Jul�Aug�Sep�Oct�Nov�Decz %d %H:%M:%S %Y GMTNr�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       r0�cert_time_to_secondsr��s����������������F�(�K�
7��|�|�I�b�q�b�M�$7�$7�$9�$9�:�:�Q�>���X�i����m�[�
1�
1���v�r�!�u�l�+�b��1��g�5�6�6�6���F�F�F��j�-6�Y�Y����E�F�F�	F�F���s�2A6�6!Bz-----BEGIN CERTIFICATE-----z-----END CERTIFICATE-----c���ttj|��dd���tg}|�fd�t	dt���d��D��z
}|�tdz��d�|��S)z[Takes a certificate in binary DER format and returns the
    PEM version of it as a string.�ASCII�strictc�*��g|]}�||dz���S)�@rD)rE�i�fs  �r0�
<listcomp>z(DER_cert_to_PEM_cert.<locals>.<listcomp>�s%���
3�
3�
3��1�Q�q��t�V�9�
3�
3�
3r2rr��
)	rK�base64�standard_b64encode�
PEM_HEADER�rangerr�
PEM_FOOTERr)�der_cert_bytes�ssr�s  @r0�DER_cert_to_PEM_certr��s����	�F�%�n�5�5�w��I�I�A�
��B��
3�
3�
3�
3�e�A�s�1�v�v�r�2�2�
3�
3�
3�3�B��I�I�j�4�� � � ��9�9�R�=�=�r2c��|�t��stdtz���|����t
��stdt
z���|���t
t��t
t
���}tj|�	dd����S)zhTakes a certificate in ASCII PEM format and returns the
    DER-encoded version of it as a byte sequencez(Invalid PEM encoding; must start with %sz&Invalid PEM encoding; must end with %sr�r�)
r-r�r��strip�endswithr�rr��decodebytesrL)�pem_cert_string�ds  r0�PEM_cert_to_DER_certr��s����%�%�j�1�1�'��C�%�&�'�'�	'�� � �"�"�+�+�J�7�7�'��A�%�&�'�'�	'�������J����Z���0@� @�A�A���a�h�h�w��9�9�:�:�:r2c�J�|\}}|�t}nt}t|||���}t||���5}|�||���5}	|	�d��}
ddd��n#1swxYwYddd��n#1swxYwYt
|
��S)a=Retrieve the certificate from the server at the specified address,
    and return it as a PEM-encoded string.
    If 'ca_certs' is specified, validate the server cert against it.
    If 'ssl_version' is specified, use it in the connection attempt.
    If 'timeout' is specified, use it in the connection attempt.
    N)r�r#)r8)rTT)r�r��_create_stdlib_contextr�rYr�r�)r�r�r�r8�host�portr�rUrP�sslsock�dercerts           r0�get_server_certificater�
s0���J�D�$���!�	�	��	�$�[�/8�,4�6�6�6�G�
�4��	1�	1�	1�0�T�
�
 �
 ��t�
 �
<�
<�	0���)�)�$�/�/�G�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0����	0�	0�	0�	0�0�0�0�0�0�0�0�0�0�0�0����0�0�0�0� ��(�(�(s5�B�A4�(B�4A8	�8B�;A8	�<B�B�Bc�8�t�|d��S)Nz	<unknown>)�_PROTOCOL_NAMESr)�
protocol_codes r0�get_protocol_namer� s�����}�k�:�:�:r2rm)prer�r�collectionsr�enumr�_Enumr�_IntEnumr�_IntFlagrrNrr	r
rrr
rrrrrrrrr+rr0rrrrr�ImportErrorrrrrr r!r"r#r$r%r&r'�	_convert_rKr(rBr+�__members__�itemsr�r�_SSLv2_IF_EXISTSrJr^rmr�r�r�r�r�r�r�r�r�r�r�r�r&rr��socket_errorr�r��HAS_NEVER_CHECK_COMMON_NAME�_RESTRICTED_SERVER_CIPHERSr�r�r�rrrrr&r:r>r;r�r�r��_create_default_https_contextr�r�rrrWr[rYr�r�r�r�r�r�r�r�rDr2r0�<module>r�s���X�X�t�
�
�
�	�	�	�	�"�"�"�"�"�"�H�H�H�H�H�H�H�H�H�H�����������N�N�N�N�N�N�N�N�N�N�3�3�3�3�3�3�3�3�3�3�������������������:�9�9�9�9�9�9�9�E�E�E�E�E�E�E�E�E�E�E�E�	����������	�	�	��D�	����
������������������������8�7�7�7�7�7�7�7�����(�K�K������
���
�x�'�'������
�����6�6������
����h�.�.������
����8�+�+������
����(�)�)������
0:�/F�F��*�,�Q�Q�*�2H�2N�2N�2P�2P�Q�Q�Q���7�:�'7��>�>����h���5�5�5�5�5�5�5���5���h���������������h���&"�&"�&"�&"�&"�&"�&"���&"�R��h��� � � � � � � ��� �:�<�7���1�1�1�1�1�1�1�1�9�9�9�9�9�9�9�9�9�9�?�?�?�?�?�?�?�?�?�?�����
�
�
�
�����������%���%�g�d�,J�K�K��.��+��.>�.>�.>�b D� D� D�F	�	�	�;0�;0�;0�| �Z� 4�����&�&�&�@�@�@�@�@�*�*�]�,H�I�I�@�@�@�*&�&�&�&�&�k�5�&�&�&�BG�BG�BG�BG�BG��BG�BG�BG�J$+�#6�$�$�"&�t�$�$�$�$�$�L4�9�*/��9L�$(�$�"&�t�D�4�4�4�4�4�n!7��4��X;�X;�X;�X;�X;�X;�X;�X;�v���|�|�|�|�|��|�|�|�@'�
��&�
��#�T�!�Y�(�4�(,�%)������@7�7�7�<+�
�
(�
����;�;�;�.A�$(�2I�)�)�)�)�,;�;�;�;�;s� A'�'A/�.A/