HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/site-packages/urllib3/util/__pycache__/ssl_match_hostname.cpython-37.pyc
B

���g��@s�dZddlmZddlZddlZddlZddlmZmZejrJddl	m
Z
dZGdd	�d	e�Z
dd
ddd
d�dd�Zdddd�dd�Zdddddd�dd�ZdS)zHThe match_hostname() function from Python 3.5, essential when using SSL.�)�annotationsN)�IPv4Address�IPv6Address�)�_TYPE_PEER_CERT_RET_DICTz3.5.0.1c@seZdZdS)�CertificateErrorN)�__name__�
__module__�__qualname__�rr�I/usr/local/lib/python3.7/site-packages/urllib3/util/ssl_match_hostname.pyrsrz
typing.Any�str�intztyping.Match[str] | None | bool)�dn�hostname�
max_wildcards�returnc
Cs�g}|sdS|�d�}|d}|dd�}|�d�}||krLtdt|���|sdt|��|��k�S|dkrx|�d�n>|�d	�s�|�d	�r�|�t�	|��n|�t�	|��
d
d��x|D]}|�t�	|��q�Wt�dd
�|�dtj
�}	|	�|�S)zhMatching according to RFC 6125, section 6.4.3

    http://tools.ietf.org/html/rfc6125#section-6.4.3
    F�.rrN�*z,too many wildcards in certificate DNS name: z[^.]+zxn--z\*z[^.]*z\Az\.z\Z)�split�countr�repr�bool�lower�append�
startswith�re�escape�replace�compile�join�
IGNORECASE�match)
rrr�pats�parts�leftmost�	remainder�	wildcards�frag�patrrr�_dnsname_matchs*


r*zIPv4Address | IPv6Addressr)�ipname�host_iprcCst�|���}t|j|jk�S)a�Exact matching of IP addresses.

    RFC 9110 section 4.3.5: "A reference identity of IP-ID contains the decoded
    bytes of the IP address. An IP version 4 address is 4 octets, and an IP
    version 6 address is 16 octets. [...] A reference identity of type IP-ID
    matches if the address is identical to an iPAddress value of the
    subjectAltName extension of the certificate."
    )�	ipaddress�
ip_address�rstripr�packed)r+r,�iprrr�_ipaddress_matchPsr2Fz_TYPE_PEER_CERT_RET_DICT | None�None)�certr�hostname_checks_common_namerc	Cs�|std��y0d|kr0t�|d|�d���}n
t�|�}Wntk
rTd}YnXg}|�dd�}xb|D]Z\}}|dkr�|dkr�t||�r�dS|�|�ql|dkrl|dk	r�t||�r�dS|�|�qlW|�r*|dk�r*|�s*xH|�dd�D]8}x2|D]*\}}|d	kr�t||��rdS|�|�q�Wq�Wt|�d
k�rVt	d|d�
tt|��f��n0t|�d
k�r~t	d
|�d|d����nt	d��dS)a)Verify that *cert* (in decoded format as returned by
    SSLSocket.getpeercert()) matches the *hostname*.  RFC 2818 and RFC 6125
    rules are followed, but IP addresses are not accepted for *hostname*.

    CertificateError is raised on failure. On success, the function
    returns nothing.
    ztempty or no certificate, match_hostname needs a SSL socket or SSL context with either CERT_OPTIONAL or CERT_REQUIRED�%N�subjectAltNamer�DNSz
IP Address�subject�
commonNamerz&hostname %r doesn't match either of %sz, z	hostname z doesn't match rz/no appropriate subjectAltName fields were found)
�
ValueErrorr-r.�rfind�getr*rr2�lenrr �mapr)	r4rr5r,�dnsnames�san�key�value�subrrr�match_hostname_sD
rE)r)F)�__doc__�
__future__rr-r�typingrr�
TYPE_CHECKING�ssl_r�__version__r;rr*r2rErrrr�<module>s7