
    hc                        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j                  e      5  ddlmZ dd	lmZ ddd       d
gZddZddZddZddZy# 1 sw Y   xY w)zA
`pyOpenSSL <https://github.com/pyca/pyopenssl>`_-specific code.
    )annotationsN)Sequence   )extract_patterns)DNS_IDCertificatePatternIPAddress_IDverify_service_identity)X509)
Connectionverify_hostnamec                b    t        t        | j                               t        |      gg        y)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   )
connectionhostnames     V/var/www/Befach/backend/env/lib/python3.12/site-packages/service_identity/pyopenssl.pyr   r      s0    0 &++-
 x()    c                b    t        t        | j                               t        |      gg        y)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   
ip_addresss     r   verify_ip_addressr   ?   s0    6 &++-
 %Z01r   c                4    t        | j                               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certs    r   r   r   c   s     *$*>*>*@AAr   c                P    t        j                  t        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   s    r   extract_idsr(   s   s&     MM#Q
 D!!r   )r   r   r   strreturnNone)r   r   r   r)   r*   r+   )r   r   r*   zSequence[CertificatePattern])__doc__
__future__r   
contextlibr%   typingr   cryptographyr   r   hazmatr   r   r	   r
   suppressImportErrorOpenSSL.cryptor   OpenSSL.SSLr   __all__r   r   r(    r   r   <module>r8      st    #    L  Z% '#&' 
B!HB "}' 's   A$$A-