Current Dir: /snap/core22/2437/usr/lib/python3/dist-packages/urllib3/packages/ssl_match_hostname/__pycache__/

[FILE] _implementation.cpython-310.pyc [ edit | delete | rename ]
[FILE] __init__.cpython-310.pyc [ edit | delete | rename ]

Viewing: /snap/core22/2437/usr/lib/python3/dist-packages/urllib3/packages/ssl_match_hostname/__pycache__/_implementation.cpython-310.pyc

o

�~�`/�@srdZddlZddlZzddlZWneydZYnwdZGdd�de�Zddd�Zd	d
�Z	dd�Z
d
d�ZdS)zJThe match_hostname() function from Python 3.3.3, essential when using SSL.�Nz3.5.0.1c@seZdZdS)�CertificateErrorN)�__name__�
__module__�__qualname__�rr�U/usr/lib/python3/dist-packages/urllib3/packages/ssl_match_hostname/_implementation.pyrsr�c
Cs�g}|sdS|�d�}|d}|dd�}|�d�}||kr&tdt|���|s0|��|��kS|dkr:|�d�n|�d	�sD|�d	�rM|�t�|��n|�t�|��	d
d��|D]
}|�t�|��q[t�
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�lower�append�
startswith�re�escape�replace�compile�join�
IGNORECASE�match)
�dn�hostname�
max_wildcards�pats�parts�leftmost�	remainder�	wildcards�frag�patrrr�_dnsname_matchs,


�
r"cCs&t|t�rtjdkrt|ddd�}|S)N)��ascii�strict)�encoding�errors)�
isinstance�str�sys�version_info�unicode)�objrrr�_to_unicodeOsr.cCst�t|����}||kS)z�Exact matching of IP addresses.

    RFC 6125 explicitly doesn't define an algorithm for this
    (section 1.7.2 - "Out of Scope").
    )�	ipaddress�
ip_addressr.�rstrip)�ipname�host_ip�iprrr�_ipaddress_matchUsr5cCsv|std��z	t�t|��}Wn%tyd}Ynty$d}Ynty4tdur1d}n�Ynwg}|�dd�}|D]/\}}|dkrY|durSt||�rSdS|�|�q?|dkrn|durit	||�ridS|�|�q?|s�|�dd�D]}|D]\}}|dkr�t||�r�dS|�|�q{qwt
|�d	kr�td
|d�t
t|��f��t
|�d	kr�td||d
f��td��)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_REQUIREDN�subjectAltNamer�DNSz
IP Address�subject�
commonNamerz&hostname %r doesn't match either of %sz, zhostname %r doesn't match %rrz=no appropriate commonName or subjectAltName fields were found)�
ValueErrorr/r0r.�UnicodeError�AttributeError�getr"rr5�lenrr�mapr
)�certrr3�dnsnames�san�key�value�subrrr�match_hostnameas`���
�

�����rF)r)�__doc__rr*r/�ImportError�__version__r:rr"r.r5rFrrrr�<module>s�
6
Upload File: