<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
B
    ¿öY  ã               @   sB   d Z ddlmZ ddlZdZG dd„ deƒZddd	„Zd
d„ ZdS )zHThe match_hostname() function from Python 3.2, essential when using SSL.é    )Úabsolute_importNz3.2.2c               @   s   e Zd ZdS )ÚCertificateErrorN)Ú__name__Ú
__module__Ú__qualname__© r   r   úO/opt/alt/python37/lib/python3.7/site-packages/raven/utils/ssl_match_hostname.pyr   
   s   r   é   c       	      C   sò   g }| sdS |   d¡}|d }| d¡}||kr@tdt| ƒ ƒ‚|sT|  ¡ | ¡ kS |dkrh| d¡ n>| d¡s|| d¡rŽ| t |¡¡ n| t |¡ 	dd	¡¡ x$|d
d… D ]}| t |¡¡ q´W t 
dd |¡ d tj¡}| |¡S )zhMatching according to RFC 6125, section 6.4.3

    http://tools.ietf.org/html/rfc6125#section-6.4.3
    FÚ.r   Ú*z,too many wildcards in certificate DNS name: z[^.]+zxn--z\*z[^.]*r	   Nz\Az\.z\Z)ÚsplitÚcountr   ÚreprÚlowerÚappendÚ
startswithÚreÚescapeÚreplaceÚcompileÚjoinÚ
IGNORECASEÚmatch)	ZdnÚhostnameZmax_wildcardsZpatsÚpartsZleftmostZ	wildcardsÚfragÚpatr   r   r   Ú_dnsname_match   s(    

r   c             C   sò   | st dƒ‚g }|  dd¡}x0|D ](\}}|dkr"t||ƒr@dS | |¡ q"W |sšxF|  dd¡D ]6}x0|D ](\}}|dkrjt||ƒrˆdS | |¡ qjW q`W t|ƒdkrÄtd	|d
 tt|ƒ¡f ƒ‚n*t|ƒdkrætd||d f ƒ‚ntdƒ‚dS )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.
    zempty or no certificateZsubjectAltNamer   ZDNSNZsubjectZ
commonNamer	   z&hostname %r doesn't match either of %sz, zhostname %r doesn't match %rr   z=no appropriate commonName or subjectAltName fields were found)	Ú
ValueErrorÚgetr   r   Úlenr   r   Úmapr   )Zcertr   ZdnsnamesZsanÚkeyÚvalueÚsubr   r   r   Úmatch_hostname@   s2    

r%   )r	   )	Ú__doc__Ú
__future__r   r   Ú__version__r   r   r   r%   r   r   r   r   Ú<module>   s   
2