Current File : //proc/self/root/usr/lib/python3.12/__pycache__/ssl.cpython-312.pyc
�

�4h���
�p�dZddlZddlZddlmZddlmZmZ	m
ZddlmZddl
Z
ddl
mZmZmZddl
mZmZmZddl
mZmZmZmZmZmZmZdd	l
mZmZdd
l
mZm Z m!Z!	ddl
m"Z"dd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.m/Z/e	j`de1d�e
��ej`de1d�e
��e	j`de1d�e
��e	j`de1d�e
��ej`de1d�e
��e	j`de1d�e
��e2jfxZ4e2_4e2jjjm�D��cic]\}}||��
c}}Z7e8e2dd�Z9ee	�Gd�d��Z:ee	�Gd�d��Z;ee	�Gd �d!��Z<ee	�Gd"�d#��Z=ej|d$k(rdd%l
m?Z?m@Z@dd&lAmAZAmBZBmCZCdd'lAmDZDmEZEmFZFddlAZGddlHZHddlIZIddlJZJeKZLd(gZMeNe
d)�ZOe.ZPeZQd*�ZRd+�ZSd,�ZTed-d.�ZUd/�ZVGd0�d1ed1d2��ZWGd3�d4eWe�ZXGd5�d6e�ZYeXj�fdddd7�d8�Z[dHe\d9eXj�dddddd:�d;�Z]e[Z^e]Z_Gd<�d=�Z`d>�ZaGd?�d@eA�ZbebeY_ce`eY_ddA�ZedBZfdCZgdD�ZhdE�ZiejdeFfdF�ZkdG�Zly#e#$rY��JwxYwcc}}w)Ia�
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_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 �/usr/lib/python3.12/ssl.py�<lambda>r0}s������-�K�$�:K�2K��)�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�6�r1�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�(�eZdZdZdZdZdZdZdZdZ	y)	�_TLSContentTypez@Content types (record layer)

    See RFC 8446, section B.1
    ������N)
rErFrG�__doc__�CHANGE_CIPHER_SPEC�ALERT�	HANDSHAKE�APPLICATION_DATA�HEADER�INNER_CONTENT_TYPErWr1r/rYrY�s*������E��I���
�F��r1rYc��eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#d"Z$d#Z%y$)%�
_TLSAlertTypezQAlert types for TLSContentType.ALERT messages

    See RFC 8466, section B.2
    r�
rZr[r\��(�)�*�+�,�-�.�/�0�1�2�3�<�F�G�P�V�Z�d�m�n�o�p�q�r�s�t�xN)&rErFrGr`�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/rhrh�s�����L����N����O������N��O� �����������J��M��L��M��������N����M�������"����&)�#�!$������!�r1rhc�h�eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZy)�_TLSMessageTypezFMessage types (handshake protocol)

    See RFC 8446, section B.3
    r����������
���rZr[r\r]��C�r_N)rErFrGr`�
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_HASHrarWr1r/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)	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        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	|���)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  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�#A?�?+B-�,B-c�>�t|j��}||k(S)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   r/�_ipaddress_matchr�ls!��
�^�*�*�,�	-�B�
��=�r1�DefaultVerifyPathszQcafile capath openssl_cafile_env openssl_cafile openssl_capath_env openssl_capathc�`�tj�}tjj	|d|d�}tjj	|d|d�}ttjj|�r|ndtjj|�r|ndg|���S)z/Return paths to default cafile and capath.
    rr�r�r�N)	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�N��eZdZdZdZ�fd�Ze�fd��Ze�fd��Z�xZ	S)�_ASN1Objectz#ASN.1 object identifier lookup
    rWc�:��t�|�|gt|d�����S)NFr-��super�__new__�_txt2obj)�cls�oid�	__class__s  �r/rz_ASN1Object.__new__�s����w��s�?�X�c��%>�?�?r1c�6��t�|�|gt|����S)z3Create _ASN1Object from OpenSSL numeric ID
        )rr�_nid2obj)r�nidrs  �r/�fromnidz_ASN1Object.fromnid�s����w��s�3�X�c�]�3�3r1c�:��t�|�|gt|d�����S)z=Create _ASN1Object from short name, long name or OID
        Tr-r
)rr.rs  �r/�fromnamez_ASN1Object.fromname�s ����w��s�?�X�d��%>�?�?r1)
rErFrGr`�	__slots__r�classmethodrr�
__classcell__�rs@r/rr�s=�����I�@��4��4�
�@��@r1rznid shortname longname oidc��eZdZdZdZdZy)�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)rErFrGr`�SERVER_AUTH�CLIENT_AUTHrWr1r/rr�s���%�K�%�Kr1rc�j��eZdZdZdZdZdZdd�Zd�Z				d d�Z			d!d�Z
d�Zd	�Zd
�Z
d�Zej fd�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)"�
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�)�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|�}�|||�S�N)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�sq�����&�	�H��h��(�A��1�v��{�c�!�f�s�l��J�K�K��M�M�#�a�&�!��M�M�!��	�	
� � ��(r1c�
�t�}	t|�D]0\}}}|dk(s�
|dus|j|vs� |j|��2	|r|j|��|S#t$rtjd�Y�6wxYw)N�x509_asnTz-unable to enumerate Windows certificate store)�cadata)rMr�rrQ�PermissionErrorr)r*�load_verify_locations)r0�	storename�purpose�certs�cert�encoding�trusts       r/�_load_windows_store_certsz$SSLContext._load_windows_store_certss������	K�):�9�)E�
+�%��h���z�)���}����u�(<����T�*�	
+���&�&�e�&�4����	�	K��M�M�I�J�	K�s�A!�A!�A!�!B�Bc���t|t�st|��tjdk(r#|j
D]}|j
||��|j�y)Nr�)r4rra�sys�platform�_windows_cert_storesrr�set_default_verify_paths)r0rmrls   r/�load_default_certszSSLContext.load_default_certssV���'�;�/��G�$�$��<�<�7�"�!�6�6�
C�	��.�.�y�'�B�
C��%�%�'r1�minimum_versionc�*��tt�|��SrY)rDrry�r0rs �r/ryzSSLContext.minimum_version�����e�g�5�6�6r1c���|tjk(r$|xjtjzc_t
tt�j||�yrY)	rDrL�optionsr3�OP_NO_SSLv3rr#ry�__set__�r0�valuers  �r/ryzSSLContext.minimum_versions?����
�(�(�(�����!4�!4� 4�4���*�j�9�A�A�$��Nr1c�*��tt�|��SrY)rDr�maximum_versionr{s �r/r�zSSLContext.maximum_version$r|r1c�J��ttt�
j||�yrY)rr#r�r�r�s  �r/r�zSSLContext.maximum_version(s����*�j�9�A�A�$��Nr1c�*��tt�|��SrY)r3rr~r{s �r/r~zSSLContext.options,s����u�w��'�'r1c�J��ttt�
j||�yrY)rr#r~r�r�s  �r/r~zSSLContext.options0s���
�j�*�-�5�5�d�E�Br1r�c�b�|jtjz}|tjk7SrY��_host_flagsrHr�)r0�ncss  r/�hostname_checks_common_namez&SSLContext.hostname_checks_common_name5s)���"�"�T�%F�%F�F�C��$�;�;�;�;r1c��|r%|xjtjzc_y|xjtjzc_yrYr�)r0r�s  r/r�z&SSLContext.hostname_checks_common_name:s6���� � �T�%F�%F�$F�F� �� � �D�$E�$E�E� r1c��y)NTrW�r0s r/r�z&SSLContext.hostname_checks_common_nameAs��r1c�6��t�|�}|�|jSy)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)r0�innerrs  �r/r�zSSLContext._msg_callbackEs%���B��%�����&�&�&�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�6wxYwrY)rDr�rYrerbrhr�)�conn�	direction�version�content_type�msg_type�data�msg_enum�callbacks       �r/r�z'SSLContext._msg_callback.<locals>.innerus����
�$�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��hasattrrar�)r0r�r�rs ` �r/r�zSSLContext._msg_callbacklsf������*�j�7�?�?��d�K���x��,��x�j�(9�:�;�;�	:�2'���
�j�*�3�;�;�D�%�Hr1c�*��tt�|��SrY)r'rr-r{s �r/r-zSSLContext.protocol�s����%�'�*�+�+r1c�*��tt�|��SrY)r<r�verify_flagsr{s �r/r�zSSLContext.verify_flags�s����5�7�/�0�0r1c�J��ttt�
j||�yrY)rr#r�r�r�s  �r/r�zSSLContext.verify_flags�s���
�j�*�2�:�:�4��Gr1c�R��t�|�}	t|�S#t$r|cYSwxYwrY)r�verify_moder?r�r�s  �r/r�zSSLContext.verify_mode�s1�����#��	��e�$�$���	��L�	�s�
�&�&c�J��ttt�
j||�yrY)rr#r�r�r�s  �r/r�zSSLContext.verify_mode�s���
�j�*�1�9�9�$��Fr1rY)FTTNN)FNN) rErFrGr`rvrArErr8rCrHrVrbrfrrrr rxr�r�propertyry�setterr�r~rHr�r�r-r�r�rrs@r/r#r#�s����>�)���O��O�	�,�-2�,0�)-�26�
� 8=�/3�
�(� (�	)��*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	ric��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)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)r4rrarr r#�PROTOCOL_TLS_CLIENT�
CERT_REQUIREDr��check_hostnamer!�PROTOCOL_TLS_SERVERr�rk�	CERT_NONErxr�rrrrt�flags�ignore_environmentr�)rmrr	rir?�
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�rm�certfile�keyfilerr	ric�l�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)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.
    Tzcertfile must be specifiedr�r�)r4rrarr r�r!r�r�r#r�r��load_cert_chainrkr�rxr�rrrrtr�r�r�)r-r�r�rmr�r�rr	rir?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��eZdZdZd�Ze		dd��Zed��Zejd��Zed��Z
e
jd��Z
ed	��Zed
��Zed��Z
dd�Zd
�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zd�Zd�Zy)�	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�F�t|jj�d���)NzU does not have a public constructor. Instances are returned by SSLContext.wrap_bio().�rarrE�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?r0rZs	         r/rBzSSLObject._create$sD���{�{�3����"�"��h�K�+���#�
��
����r1c�.�|jjS)z(The SSLContext that is currently in use.�r�r?r�s r/r?zSSLObject.context0����|�|�#�#�#r1c�&�||j_yrYr��r0�ctxs  r/r?zSSLObject.context5s��"����r1c�.�|jjS)z!The SSLSession for client socket.�r�r@r�s r/r@zSSLObject.session9r�r1c�&�||j_yrYr��r0r@s  r/r@zSSLObject.session>s��&����r1c�.�|jjS)z.Was the client session reused during handshake�r��session_reusedr�s r/r�zSSLObject.session_reusedBs���|�|�*�*�*r1c�.�|jjS)z%Whether this is a server-side socket.)r�r;r�s r/r;zSSLObject.server_sideGs���|�|�'�'�'r1c�.�|jjS)z^The currently set server hostname (for SNI), or ``None`` if no
        server hostname is set.)r�r>r�s r/r>zSSLObject.server_hostnameLs���|�|�+�+�+r1c�|�|�|jj||�}|S|jj|�}|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)r0rO�buffer�vs    r/r�zSSLObject.readRsB�������!�!�#�v�.�A������!�!�#�&�A��r1c�8�|jj|�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�r0r�s  r/r�zSSLObject.write^s���|�|�!�!�$�'�'r1c�8�|jj|�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�r0�binary_forms  r/r�zSSLObject.getpeercertfs���|�|�'�'��4�4r1c�<�tjdtd��y)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.rJr�rKN)r)r*r+r�s r/�selected_npn_protocolzSSLObject.selected_npn_protocolos��	�
�
�5���	
r1c�6�|jj�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 r/r�z SSLObject.selected_alpn_protocolys���|�|�2�2�4�4r1c�6�|jj�S)z_Return the currently selected cipher as a 3-tuple ``(name,
        ssl_version, secret_bits)``.)r��cipherr�s r/r�zSSLObject.ciphers���|�|�"�"�$�$r1c�6�|jj�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 r/r�zSSLObject.shared_ciphers�s���|�|�*�*�,�,r1c�6�|jj�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 r/r�zSSLObject.compression�s���|�|�'�'�)�)r1c�6�|jj�S)z8Return the number of bytes that can be read immediately.)r��pendingr�s r/r�zSSLObject.pending�s���|�|�#�#�%�%r1c�8�|jj�y)zStart the SSL/TLS handshake.N)r��do_handshaker�s r/r�zSSLObject.do_handshake�s�����!�!�#r1c�6�|jj�S)z!Start the SSL shutdown handshake.)r��shutdownr�s r/�unwrapzSSLObject.unwrap�s���|�|�$�$�&�&r1c�8�|jj|�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�r0�cb_types  r/r�zSSLObject.get_channel_binding�s���|�|�/�/��8�8r1c�6�|jj�S)zZReturn a string identifying the protocol version used by the
        current SSL channel. �r�r�r�s r/r�zSSLObject.version�s���|�|�#�#�%�%r1c�6�|jj�SrY)r��verify_client_post_handshaker�s r/r�z&SSLObject.verify_client_post_handshake�s���|�|�8�8�:�:r1)FNNN��N�F�r�)rErFrGr`r�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�X�tt|j�j|_|S)z*Copy docstring from SSLObject to SSLSocket)�getattrr�rEr`)�funcs r/�_sslcopydocr��s���9�d�m�m�4�<�<�D�L��Kr1c�^��eZdZdZd�Ze			d+�fd�	�Zeed���Z	e	jd��Z	eed���Zejd��Zeed���Zd	�Z
d,d
�Zd�Zd-d�Zd
�Zed.d��Zed��Zed��Zed��Zed��Zed��Zd/�fd�	Zd,�fd�	Zd�Zd/�fd�	Zd0�fd�	Zd1�fd�	Zd2�fd�	Zd1�fd�	Zd2�fd�	Z d�Z!d�Z"ed��Z#�fd �Z$ed!��Z%ed"��Z&�fd#�Z'ed.d$��Z(�fd%�Z)d&�Z*d'�Z+�fd(�Z,ed3d)��Z-ed*��Z.�xZ/S)4�	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�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��|jSrY)rr�s r/r?zSSLSocket.contexts���}�}�r1c�4�||_||j_yrY)rr�r?r�s  r/r?zSSLSocket.context s����
�"����r1c�H�|j�|jjSyrYr�r�s r/r@zSSLSocket.session%s#���<�<�#��<�<�'�'�'�$r1c�N�||_|j�||j_yyrY)rr�r@r�s  r/r@zSSLSocket.session+s$����
��<�<�#�#*�D�L�L� �$r1c�H�|j�|jjSyrYr�r�s r/r�zSSLSocket.session_reused1s#���<�<�#��<�<�.�.�.�$r1c�F�td|jjz��)NzCan't dup() %s instances)rrrEr�s r/�dupz
SSLSocket.dup7s$��!�"<�"&�.�.�"9�"9�#:�;�	;r1c��yrYrW)r0�msgs  r/�_checkClosedzSSLSocket._checkClosed;s��r1c�>�|js|j�yyrY)rrr�s r/�_check_connectedzSSLSocket._check_connected?s�����

����r1c�D�|j�|j�td��	|�|jj||�S|jj|�S#t$r4}|j
dtk(r|jr|�Yd}~yYd}~y�d}~wwxYw)zORead up to LEN bytes and return them.
        Return zero-length string on EOF.Nz'Read on closed or unwrapped SSL socket.rr1)r/r�r�r�rr.�
SSL_ERROR_EOFr=)r0rOr��xs    r/r�zSSLSocket.readGs���	
�����<�<���F�G�G�	��!��|�|�(�(��f�5�5��|�|�(�(��-�-���	��v�v�a�y�M�)�d�.G�.G��%�����	�s#�A"�A"�"	B�+$B�B�Bc��|j�|j�td��|jj|�S)zhWrite DATA to the underlying SSL channel.  Returns
        number of bytes of DATA actually transmitted.z(Write on closed or unwrapped SSL socket.)r/r�r�r�r�s  r/r�zSSLSocket.write\s;��	
�����<�<���G�H�H��|�|�!�!�$�'�'r1c�x�|j�|j�|jj|�SrY)r/r1r�r�r�s  r/r�zSSLSocket.getpeercertes/�����������|�|�'�'��4�4r1c�\�|j�tjdtd��y)NrJr�rK)r/r)r*r+r�s r/r�zSSLSocket.selected_npn_protocolks(�������
�
�5���	
�
r1c��|j�|j�tjsy|jj	�SrY)r/r�rHrr�r�s r/r�z SSLSocket.selected_alpn_protocolus4�������<�<��t�}�}���<�<�6�6�8�8r1c�p�|j�|j�y|jj�SrY)r/r�r�r�s r/r�zSSLSocket.cipher}s.�������<�<����<�<�&�&�(�(r1c�p�|j�|j�y|jj�SrY)r/r�r�r�s r/r�zSSLSocket.shared_ciphers�s.�������<�<����<�<�.�.�0�0r1c�p�|j�|j�y|jj�SrY)r/r�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)r/r�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)r/r�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�rrr�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)
r/r�r�r�
memoryview�castrOr=r�sendall)	r0r�r�r��view�	byte_view�amountr�rs	        �r/rHzSSLSocket.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�d��|j�|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)r0�file�offsetr�rs    �r/rNzSSLSocket.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)r/r�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)	r/rF�nbytesr�r�rr�r�	recv_into)r0r�rUr�rIrs     �r/rVzSSLSocket.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)r/r�r�rr�recvfromrRs   �r/rXzSSLSocket.recvfrom�sI��������<�<�#��F�!�^�^�,�-�
-��7�#�F�E�2�2r1c���|j�|j�td|jz��t�|�|||�S)Nz,recvfrom_into not allowed on instances of %s)r/r�r�rr�
recvfrom_into)r0r�rUr�rs    �r/rZzSSLSocket.recvfrom_into�sK��������<�<�#��K�!�^�^�,�-�
-��7�(����?�?r1c�2�td|jz��)Nz&recvmsg not allowed on instances of %srBr�s   r/�recvmsgzSSLSocket.recvmsg�s��!�"J�"&�.�.�#1�2�	2r1c�2�td|jz��)Nz+recvmsg_into not allowed on instances of %srBr�s   r/�recvmsg_intozSSLSocket.recvmsg_into�s ��!�#'�)-���#8�9�	9r1c�p�|j�|j�|jj�Sy�Nr)r/r�r�r�s r/r�zSSLSocket.pendings.�������<�<�#��<�<�'�'�)�)�r1c�R��|j�d|_t�|�
|�yrY)r/r�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��rd)r�r�r�r5r�s r/r�z&SSLSocket.verify_client_post_handshakes1���<�<��<�<�<�<�>�>��5��D�	�A�B�Br1c�0��d|_t�|�	�yrY)r�r�_real_closer{s �r/rhzSSLSocket._real_closes������
���r1c��|j�|j�}	|dk(r|r|jd�|jj	�|j|�y#|j|�wxYw)Nr	)r1r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!FrT)r;r�rr�r?rr>rr�
connect_ex�connectr<r�r�)r0r�rl�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)�QConnects to remote ADDR, and then wraps the connection in
        an SSL channel.FN�ro�r0r�s  r/rmzSSLSocket.connectFs��	
���4��'r1c�&�|j|d�S)rqTrrrss  r/rlzSSLSocket.connect_exKs���!�!�$��-�-r1c���t�|��\}}|jj||j|j
d��}||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)r<r=r;)r�acceptr?rCr<r=)r0�newsockr�rs   �r/rvzSSLSocket.acceptPsQ���
���(�
����,�,�*�*�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�SyrYr�r�s r/r�zSSLSocket.versiongs"���<�<�#��<�<�'�'�)�)�r1)FTTNNNrYr�r�)r)rN)r�rr`r�)0rErFrGr`r�rrBr�r�r?r�r@r�r,r/r1r�r�r�r�r�r�r�r�r=r?rCrHrNrrVrXrZr\r^r�r�r�r�rhr�rormrlrvr�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|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       r/�cert_time_to_secondsr�vs������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�A2z-----BEGIN CERTIFICATE-----z-----END CERTIFICATE-----c��ttj|�dd�}tg}|t	dt|�d�D�cgc]
}|||dz��c}z
}|j
tdz�dj|�Scc}w)z[Takes a certificate in binary DER format and returns the
    PEM version of it as a string.�ASCII�strictr�@�
)	r5�base64�standard_b64encode�
PEM_HEADER�rangerOrP�
PEM_FOOTER�join)�der_cert_bytes�f�ss�is    r/�DER_cert_to_PEM_certr��st��	�F�%�%�n�5�w��I�A�
��B��e�A�s�1�v�r�2�
3��1�Q�q��t�9�
3�3�B��I�I�j�4�� ��9�9�R�=���4s�A>c�`�|jt�stdtz��|j�j	t
�stdt
z��|j�t
t�t
t
�}tj|jdd��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�rOr��decodebytesr6)�pem_cert_string�ds  r/�PEM_cert_to_DER_certr��s����%�%�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)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)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�0�T�
�
 �
 ��t�
 �
<�	0���)�)�$�/�G�	0�0� ��(�(�	0�	0��0� ��(�(�s#�A=�A1�A=�1A:	�6A=�=Bc�.�tj|d�S)Nz	<unknown>)�_PROTOCOL_NAMESr)�
protocol_codes r/�get_protocol_namer��s�����}�k�:�:r1rY)mr`rtr�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_EXISTSrDrYrhr�rur�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�r�rrArEr�r�r�r�r�r�r�r�)r.r�s00r/�<module>r�s[��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�;�4��5�$�;�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�&�BG��BG�J$+�#6�#6�$�$�"&�t�$�L4�9�*/��9L�9L�$(�$�"&�t�D�4�n!7��4��X;�X;�v�|��|�@'�
��&�
��
7�<+�
�
(�
��;�.A�$(�2I�)�,;��i*�	��	��TRs�J&�>
J2�&J/�.J/
¿Qué es la limpieza dental de perros? - Clínica veterinaria


Es la eliminación del sarro y la placa adherida a la superficie de los dientes mediante un equipo de ultrasonidos que garantiza la integridad de las piezas dentales a la vez que elimina en profundidad cualquier resto de suciedad.

A continuación se procede al pulido de los dientes mediante una fresa especial que elimina la placa bacteriana y devuelve a los dientes el aspecto sano que deben tener.

Una vez terminado todo el proceso, se mantiene al perro en observación hasta que se despierta de la anestesia, bajo la atenta supervisión de un veterinario.

¿Cada cuánto tiempo tengo que hacerle una limpieza dental a mi perro?

A partir de cierta edad, los perros pueden necesitar una limpieza dental anual o bianual. Depende de cada caso. En líneas generales, puede decirse que los perros de razas pequeñas suelen acumular más sarro y suelen necesitar una atención mayor en cuanto a higiene dental.


Riesgos de una mala higiene


Los riesgos más evidentes de una mala higiene dental en los perros son los siguientes:

  • Cuando la acumulación de sarro no se trata, se puede producir una inflamación y retracción de las encías que puede descalzar el diente y provocar caídas.
  • Mal aliento (halitosis).
  • Sarro perros
  • Puede ir a más
  • Las bacterias de la placa pueden trasladarse a través del torrente circulatorio a órganos vitales como el corazón ocasionando problemas de endocarditis en las válvulas. Las bacterias pueden incluso acantonarse en huesos (La osteomielitis es la infección ósea, tanto cortical como medular) provocando mucho dolor y una artritis séptica).

¿Cómo se forma el sarro?

El sarro es la calcificación de la placa dental. Los restos de alimentos, junto con las bacterias presentes en la boca, van a formar la placa bacteriana o placa dental. Si la placa no se retira, al mezclarse con la saliva y los minerales presentes en ella, reaccionará formando una costra. La placa se calcifica y se forma el sarro.

El sarro, cuando se forma, es de color blanquecino pero a medida que pasa el tiempo se va poniendo amarillo y luego marrón.

Síntomas de una pobre higiene dental
La señal más obvia de una mala salud dental canina es el mal aliento.

Sin embargo, a veces no es tan fácil de detectar
Y hay perros que no se dejan abrir la boca por su dueño. Por ejemplo…

Recientemente nos trajeron a la clínica a un perro que parpadeaba de un ojo y decía su dueño que le picaba un lado de la cara. Tenía molestias y dificultad para comer, lo que había llevado a sus dueños a comprarle comida blanda (que suele ser un poco más cara y llevar más contenido en grasa) durante medio año. Después de una exploración oftalmológica, nos dimos cuenta de que el ojo tenía una úlcera en la córnea probablemente de rascarse . Además, el canto lateral del ojo estaba inflamado. Tenía lo que en humanos llamamos flemón pero como era un perro de pelo largo, no se le notaba a simple vista. Al abrirle la boca nos llamó la atención el ver una muela llena de sarro. Le realizamos una radiografía y encontramos una fístula que llegaba hasta la parte inferior del ojo.

Le tuvimos que extraer la muela. Tras esto, el ojo se curó completamente con unos colirios y una lentilla protectora de úlcera. Afortunadamente, la úlcera no profundizó y no perforó el ojo. Ahora el perro come perfectamente a pesar de haber perdido una muela.

¿Cómo mantener la higiene dental de tu perro?
Hay varias maneras de prevenir problemas derivados de la salud dental de tu perro.

Limpiezas de dientes en casa
Es recomendable limpiar los dientes de tu perro semanal o diariamente si se puede. Existe una gran variedad de productos que se pueden utilizar:

Pastas de dientes.
Cepillos de dientes o dedales para el dedo índice, que hacen más fácil la limpieza.
Colutorios para echar en agua de bebida o directamente sobre el diente en líquido o en spray.

En la Clínica Tus Veterinarios enseñamos a nuestros clientes a tomar el hábito de limpiar los dientes de sus perros desde que son cachorros. Esto responde a nuestro compromiso con la prevención de enfermedades caninas.

Hoy en día tenemos muchos clientes que limpian los dientes todos los días a su mascota, y como resultado, se ahorran el dinero de hacer limpiezas dentales profesionales y consiguen una mejor salud de su perro.


Limpiezas dentales profesionales de perros y gatos

Recomendamos hacer una limpieza dental especializada anualmente. La realizamos con un aparato de ultrasonidos que utiliza agua para quitar el sarro. Después, procedemos a pulir los dientes con un cepillo de alta velocidad y una pasta especial. Hacemos esto para proteger el esmalte.

La frecuencia de limpiezas dentales necesaria varía mucho entre razas. En general, las razas grandes tienen buena calidad de esmalte, por lo que no necesitan hacerlo tan a menudo e incluso pueden pasarse la vida sin requerir una limpieza. Sin embargo, razas pequeñas como el Yorkshire o el Maltés, deben hacérselas todos los años desde cachorros si se quiere conservar sus piezas dentales.

Otro factor fundamental es la calidad del pienso. Algunas marcas han diseñado croquetas que limpian la superficie del diente y de la muela al masticarse.

Ultrasonido para perros

¿Se necesita anestesia para las limpiezas dentales de perros y gatos?

La limpieza dental en perros no es una técnica que pueda practicarse sin anestesia general , aunque hay veces que los propietarios no quieren anestesiar y si tiene poco sarro y el perro es muy bueno se puede intentar…… , pero no se va a poder pulir ni acceder a todas la zona de la boca …. Además los limpiadores dentales van a irrigar agua y hay riesgo de aspiración a vías respiratorias si no se realiza una anestesia correcta con intubación traqueal . En resumen , sin anestesia no se va hacer una correcta limpieza dental.

Tampoco sirve la sedación ya que necesitamos que el animal esté totalmente quieto, y el veterinario tenga un acceso completo a todas sus piezas dentales y encías.

Alimentos para la limpieza dental

Hay que tener cierto cuidado a la hora de comprar determinados alimentos porque no todos son saludables. Algunos tienen demasiado contenido graso, que en exceso puede causar problemas cardiovasculares y obesidad.

Los mejores alimentos para los dientes son aquellos que están elaborados por empresas farmacéuticas y llevan componentes químicos con tratamientos específicos para el diente del perro. Esto implica no solo limpieza a través de la acción mecánica de morder sino también un tratamiento antibacteriano para prevenir el sarro.

Conclusión

Si eres como la mayoría de dueños, por falta de tiempo , es probable que no estés prestando la suficiente atención a la limpieza dental de tu perro. Por eso te animamos a que comiences a limpiar los dientes de tu perro y consideres atender a su higiene bucal con frecuencia.

Estas simples medidas pueden conllevar a que tu perro tenga una vida más larga y mucho más saludable.

Si te resulta imposible introducir un cepillo de dientes a tu perro en la boca, pásate con él por clínica Tus Veterinarios y te explicamos cómo hacerlo.

Necesitas hacer una limpieza dental profesional a tu mascota?
Llámanos al 622575274 o contacta con nosotros

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

¡Hola!