§
    ÌtºfÍ  ã                  ó:  — 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
 ddlmZ ddlmZ d	d
lmZ d	dlmZmZmZmZ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¦  «         n# 1 swxY w Y   dgZ dd„Z!dd„Z" ed¦  «        Z#d d„Z$d d„Z%dS )!zA
`pyOpenSSL <https://github.com/pyca/pyopenssl>`_-specific code.
é    )ÚannotationsN)ÚSequence)Údecode)Ú	IA5String)ÚObjectIdentifier)ÚGeneralNamesé   )ÚCertificateError)ÚDNS_IDÚCertificatePatternÚ
DNSPatternÚIPAddress_IDÚIPAddressPatternÚ
SRVPatternÚ
URIPatternÚverify_service_identity)ÚX509)Ú
ConnectionÚverify_hostnameÚ
connectionr   ÚhostnameÚstrÚreturnÚNonec                ó„   — t          t          |                      ¦   «         ¦  «        t          |¦  «        gg ¬¦  «         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   Úextract_patternsÚget_peer_certificater   )r   r   s     úY/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/service_identity/pyopenssl.pyr   r   '   sT   € õ0 Ý&Ø×+Ò+Ñ-Ô-ñ
ô 
õ ˜xÑ(Ô(Ð)Øðñ ô ð ð ð ó    Ú
ip_addressc                ó„   — t          t          |                      ¦   «         ¦  «        t          |¦  «        gg ¬¦  «         dS )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$   s     r"   Úverify_ip_addressr&   H   sT   € õ6 Ý&Ø×+Ò+Ñ-Ô-ñ
ô 
õ % ZÑ0Ô0Ð1Øðñ ô ð ð ð r#   z1.3.6.1.5.5.7.8.7Úcertr   úSequence[CertificatePattern]c                óº  — g }t          |                      ¦   «         ¦  «        D �]5}|                      |¦  «        }|                     ¦   «         dk    �rt	          |                     ¦   «         t          ¦   «         ¬¦  «        \  }}|D �]Î}|                     ¦   «         }|dk    rL|                     t          j
        |                     ¦   «                              ¦   «         ¦  «        ¦  «         Œi|dk    rL|                     t          j
        |                     ¦   «                              ¦   «         ¦  «        ¦  «         Œ»|dk    rM|                     t          j
        |                     ¦   «                              ¦   «         ¦  «        ¦  «         �Œ|dk    rº|                     ¦   «         }|                     d¦  «        }	|	t           k    r„t	          |                     d¦  «        ¦  «        \  }
}t#          |
t$          ¦  «        r;|                     t'          j
        |
                     ¦   «         ¦  «        ¦  «         �Œ½t)          d	¦  «        ‚�ŒÎ�ŒÐ�Œ7|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.
    s   subjectAltName)Úasn1SpecÚdNSNameÚ	iPAddressÚuniformResourceIdentifierÚ	otherNamer   r	   zUnexpected certificate content.)ÚrangeÚget_extension_countÚget_extensionÚget_short_namer   Úget_datar   ÚgetNameÚappendr   Ú
from_bytesÚgetComponentÚasOctetsr   r   ÚgetComponentByPositionÚID_ON_DNS_SRVÚ
isinstancer   r   r
   )r'   ÚidsÚiÚextÚnamesÚ_ÚnÚname_stringÚcompÚoidÚsrvs              r"   r    r    o   s3  € ð %'€CÝ�4×+Ò+Ñ-Ô-Ñ.Ô.ð "ñ "ˆØ× Ò  Ñ#Ô#ˆØ×ÒÑÔÐ#4Ò4Ñ4Ý˜cŸlšl™nœnµ|±~´~ÐFÑFÔF‰HˆE�1Øð ñ �ØŸiši™kœk�Ø )Ò+Ð+Ø—J’JÝ"Ô-¨a¯nªnÑ.>Ô.>×.GÒ.GÑ.IÔ.IÑJÔJñô ð ð ð ! KÒ/Ð/Ø—J’JÝ(Ô3ØŸNšNÑ,Ô,×5Ò5Ñ7Ô7ñô ñô ð ð ð
 !Ð$?Ò?Ð?Ø—J’JÝ"Ô-¨a¯nªnÑ.>Ô.>×.GÒ.GÑ.IÔ.IÑJÔJñô ð ñ ð ! KÒ/Ð/ØŸ>š>Ñ+Ô+�DØ×5Ò5°aÑ8Ô8�CØ�mÒ+Ð+Ý!'¨×(CÒ(CÀAÑ(FÔ(FÑ!GÔ!G™˜˜QÝ% c­9Ñ5Ô5ð ØŸJšJ¥zÔ'<¸S¿\º\¹^¼^Ñ'LÔ'LÑMÔMÐMÑMå"2Ø Añ#ô #ð ñ áùà€Jr#   c                óX   — 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_idsrN   ¤   s6   € õ „MÝ#ØQØðñ ô ð õ
 ˜DÑ!Ô!Ð!r#   )r   r   r   r   r   r   )r   r   r$   r   r   r   )r'   r   r   r(   )&Ú__doc__Ú
__future__r   Ú
contextlibrK   Útypingr   Úpyasn1.codec.der.decoderr   Úpyasn1.type.charr   Úpyasn1.type.univr   Úpyasn1_modules.rfc2459r   Ú
exceptionsr
   Úhazmatr   r   r   r   r   r   r   r   ÚsuppressÚImportErrorÚOpenSSL.cryptor   ÚOpenSSL.SSLr   Ú__all__r   r&   r:   r    rN   © r#   r"   ú<module>r_      s  ððð ð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø €€€à Ð Ð Ð Ð Ð à +Ð +Ð +Ð +Ð +Ð +Ø &Ð &Ð &Ð &Ð &Ð &Ø -Ð -Ð -Ð -Ð -Ð -Ø /Ð /Ð /Ð /Ð /Ð /à (Ð (Ð (Ð (Ð (Ð (ð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð €ZÔ˜Ñ%Ô%ð 'ð 'à#Ð#Ð#Ð#Ð#Ð#Ø&Ð&Ð&Ð&Ð&Ð&ð'ð 'ð 'ñ 'ô 'ð 'ð 'ð 'ð 'ð 'ð 'øøøð 'ð 'ð 'ð 'ð Ð
€ðð ð ð ðB!ð !ð !ð !ðH !Ð Ð!4Ñ5Ô5€ð2ð 2ð 2ð 2ðj"ð "ð "ð "ð "ð "s   ÁA2Á2A6Á9A6