o
    >hc                     @  s   d Z ddlmZ ddlZddlZddlmZ ddlmZ	 ddl
mZmZmZmZ ee ddlmZ dd	lmZ W d   n1 sDw   Y  d
gZddd
ZdddZdddZdddZdS )zA
`pyOpenSSL <https://github.com/pyca/pyopenssl>`_-specific code.
    )annotationsN)Sequence   )extract_patterns)DNS_IDCertificatePatternIPAddress_IDverify_service_identity)X509)
Connectionverify_hostname
connectionr   hostnamestrreturnNonec                 C      t t|  t|gg d dS )a;  
    Verify whether the certificate of *connection* is valid for *hostname*.

    Args:
        connection: A pyOpenSSL connection object.

        hostname: The hostname that *connection* should be connected to.

    Raises:
        service_identity.VerificationError:
            If *connection* does not provide a certificate that is valid for
            *hostname*.

        service_identity.CertificateError:
            If certificate provided by *connection* contains invalid /
            unexpected data. This includes the case where the certificate
            contains no ``subjectAltName``\ s.

    .. versionchanged:: 24.1.0
        :exc:`~service_identity.CertificateError` is raised if the certificate
        contains no ``subjectAltName``\ s instead of
        :exc:`~service_identity.VerificationError`.
    cert_patternsobligatory_idsoptional_idsN)r	   r   get_peer_certificater   )r   r    r   z/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/service_identity/pyopenssl.pyr      s   

ip_addressc                 C  r   )aX  
    Verify whether the certificate of *connection* is valid for *ip_address*.

    Args:
        connection: A pyOpenSSL connection object.

        ip_address:
            The IP address that *connection* should be connected to. Can be an
            IPv4 or IPv6 address.

    Raises:
        service_identity.VerificationError:
            If *connection* does not provide a certificate that is valid for
            *ip_address*.

        service_identity.CertificateError:
            If the certificate chain of *connection* contains a certificate
            that contains invalid/unexpected data.

    .. versionadded:: 18.1.0

    .. versionchanged:: 24.1.0
        :exc:`~service_identity.CertificateError` is raised if the certificate
        contains no ``subjectAltName``\ s instead of
        :exc:`~service_identity.VerificationError`.
    r   N)r	   r   r   r   )r   r   r   r   r   verify_ip_address?   s   
r   certr
   Sequence[CertificatePattern]c                 C  s   t |  S )a
  
    Extract all valid ID patterns from a certificate for service verification.

    Args:
        cert: The certificate to be dissected.

    Returns:
        List of IDs.

    .. versionchanged:: 23.1.0
       ``commonName`` is not used as a fallback anymore.
    )_cryptography_extract_patternsto_cryptographyr   r   r   r   r   c   s   r   c                 C  s   t jtddd t| S )zm
    Deprecated and never public API.  Use :func:`extract_patterns` instead.

    .. deprecated:: 23.1.0
    z?`extract_ids()` is deprecated, please use `extract_patterns()`.   )categorymessage
stacklevel)warningswarnDeprecationWarningr   r    r   r   r   extract_idss   s   r(   )r   r   r   r   r   r   )r   r   r   r   r   r   )r   r
   r   r   )__doc__
__future__r   
contextlibr%   typingr   cryptographyr   r   hazmatr   r   r   r	   suppressImportErrorOpenSSL.cryptor
   OpenSSL.SSLr   __all__r   r   r(   r   r   r   r   <module>   s     

!
$