§
    Ìtºf  ã                  óâ   — d Z ddlmZ ddlZddlmZ ddlmZmZm	Z	m
Z
mZmZ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 dgZdd„Z dd„Z! ed¦  «        Z"dd„Z#dd„Z$dS )zL
`cryptography.x509 <https://github.com/pyca/cryptography>`_-specific code.
é    )ÚannotationsN)ÚSequence)ÚCertificateÚDNSNameÚExtensionOIDÚ	IPAddressÚObjectIdentifierÚ	OtherNameÚUniformResourceIdentifier)ÚExtensionNotFound)Údecode)Ú	IA5Stringé   )ÚCertificateError)ÚDNS_IDÚCertificatePatternÚ
DNSPatternÚIPAddress_IDÚIPAddressPatternÚ
SRVPatternÚ
URIPatternÚverify_service_identityÚverify_certificate_hostnameÚcertificater   ÚhostnameÚstrÚreturnÚNonec                ó`   — t          t          | ¦  «        t          |¦  «        gg ¬¦  «         dS )a¤  
    Verify whether *certificate* is valid for *hostname*.

    .. note::
        Nothing is verified about the *authority* of the certificate;
        the caller must verify that the certificate chains to an appropriate
        trust root themselves.

    Args:
        certificate: A *cryptography* X509 certificate object.

        hostname: The hostname that *certificate* should be valid for.

    Raises:
        service_identity.VerificationError:
            If *certificate* is not valid for *hostname*.

        service_identity.CertificateError:
            If *certificate* 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_patternsr   )r   r   s     ú\/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/service_identity/cryptography.pyr   r   (   sA   € õ: Ý& {Ñ3Ô3Ý˜xÑ(Ô(Ð)Øðñ ô ð ð ð ó    Ú
ip_addressc                ó`   — t          t          | ¦  «        t          |¦  «        gg ¬¦  «         dS )a  
    Verify whether *certificate* is valid for *ip_address*.

    .. note::
        Nothing is verified about the *authority* of the certificate;
        the caller must verify that the certificate chains to an appropriate
        trust root themselves.

    Args:
        certificate: A *cryptography* X509 certificate object.

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

    Raises:
        service_identity.VerificationError:
            If *certificate* is not valid for *ip_address*.

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

    .. 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'   s     r%   Úverify_certificate_ip_addressr)   L   sB   € õB Ý& {Ñ3Ô3Ý$ ZÑ0Ô0Ð1Øðñ ô ð ð ð r&   z1.3.6.1.5.5.7.8.7ÚcertúSequence[CertificatePattern]c                ó,  — g }	 | j                              t          j        ¦  «        }|                     d„ |j                             t          ¦  «        D ¦   «         ¦  «         |                     d„ |j                             t          ¦  «        D ¦   «         ¦  «         |                     d„ |j                             t          ¦  «        D ¦   «         ¦  «         |j                             t          ¦  «        D ]‡}|j        t          k    rut          |j        ¦  «        \  }}t          |t          ¦  «        r:|                     t#          j        |                     ¦   «         ¦  «        ¦  «         Œxt)          d¦  «        ‚Œˆn# t*          $ r Y nw xY w|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.
    c                ó\   — g | ])}t          j        |                     d ¦  «        ¦  «        ‘Œ*S ©zutf-8)r   Ú
from_bytesÚencode)Ú.0Únames     r%   ú
<listcomp>z$extract_patterns.<locals>.<listcomp>�   s?   € ð ð ð àõ Ô% d§k¢k°'Ñ&:Ô&:Ñ;Ô;ðð ð r&   c                ó\   — g | ])}t          j        |                     d ¦  «        ¦  «        ‘Œ*S r.   )r   r/   r0   )r1   Úuris     r%   r3   z$extract_patterns.<locals>.<listcomp>“   s?   € ð ð ð àõ Ô% c§j¢j°Ñ&9Ô&9Ñ:Ô:ðð ð r&   c                ó,   — g | ]}t          |¦  «        ‘ŒS © )r   )r1   Úips     r%   r3   z$extract_patterns.<locals>.<listcomp>›   s0   € ð ð ð àõ ! Ñ$Ô$ðð ð r&   zUnexpected certificate content.)Ú
extensionsÚget_extension_for_oidr   ÚSUBJECT_ALTERNATIVE_NAMEÚextendÚvalueÚget_values_for_typer   r   r   r
   Útype_idÚID_ON_DNS_SRVr   Ú
isinstancer   Úappendr   r/   ÚasOctetsr   r   )r*   ÚidsÚextÚotherÚsrvÚ_s         r%   r$   r$   w   s¾  € ð %'€Cð!NØŒo×3Ò3ÝÔ1ñ
ô 
ˆð 	�
Š
ðð àœI×9Ò9½'ÑBÔBðñ ô ñ	
ô 	
ð 	
ð 	�
Š
ðð àœ9×8Ò8Ý-ñô ðñ ô ñ	
ô 	
ð 	
ð 	�
Š
ðð àœ)×7Ò7½	ÑBÔBðñ ô ñ	
ô 	
ð 	
ð ”Y×2Ò2µ9Ñ=Ô=ð 	Nð 	NˆEØŒ}¥Ò-Ð-Ý ¤Ñ,Ô,‘��QÝ˜c¥9Ñ-Ô-ð NØ—J’J�zÔ4°S·\²\±^´^ÑDÔDÑEÔEÐEÐEå*Ð+LÑMÔMÐMð .ð	Nøõ/ ð ð ð Øˆðøøøð> €Js   „$F Æ
FÆF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_idsrQ   «   s6   € õ „MÝ#ØQØðñ ô ð õ
 ˜DÑ!Ô!Ð!r&   )r   r   r   r   r   r   )r   r   r'   r   r   r   )r*   r   r   r+   )%Ú__doc__Ú
__future__r   rN   Útypingr   Úcryptography.x509r   r   r   r   r	   r
   r   Úcryptography.x509.extensionsr   Úpyasn1.codec.der.decoderr   Úpyasn1.type.charr   Ú
exceptionsr   Úhazmatr   r   r   r   r   r   r   r   Ú__all__r   r)   r@   r$   rQ   r7   r&   r%   ú<module>r\      sÀ  ððð ð #Ð "Ð "Ð "Ð "Ð "à €€€à Ð Ð Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ;Ð :Ð :Ð :Ð :Ð :Ø +Ð +Ð +Ð +Ð +Ð +Ø &Ð &Ð &Ð &Ð &Ð &à (Ð (Ð (Ð (Ð (Ð (ð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð )Ð
)€ð!ð !ð !ð !ðH%ð %ð %ð %ðP !Ð Ð!4Ñ5Ô5€ð1ð 1ð 1ð 1ðh"ð "ð "ð "ð "ð "r&   