
    &th~                     z    d Z ddlZddlZ	 ddlZn# e$ r dZY nw xY wdZ G d de          ZddZd Z	d	 Z
d
 ZdS )zJThe match_hostname() function from Python 3.3.3, essential when using SSL.    Nz3.5.0.1c                       e Zd ZdS )CertificateErrorN)__name__
__module____qualname__     s/var/www/html/mycamper/aliexpress-site/backend/venv/lib/python3.11/site-packages/urllib3/util/ssl_match_hostname.pyr   r      s        Dr	   r      c                 l   g }| sdS |                      d          }|d         }|dd         }|                    d          }||k    rt          dt          |           z             |s*|                                 |                                k    S |dk    r|                    d           n|                    d	          s|                    d	          r(|                    t          j        |                     n;|                    t          j        |          	                    d
d                     |D ])}|                    t          j        |                     *t          j
        dd                    |          z   dz   t          j                  }	|	                    |          S )zhMatching according to RFC 6125, section 6.4.3

    http://tools.ietf.org/html/rfc6125#section-6.4.3
    F.r   r   N*z,too many wildcards in certificate DNS name: z[^.]+zxn--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pats
             r
   _dnsname_matchr&      s   
 D u HHTNNEQxHabb	Is##I=  
 :T"XXE
 
 	

  .xxzzX^^----
 3 	G			V	$	$ A(;(;F(C(C A
 	BIh''(((( 	BIh''//w??@@@  % %BIdOO$$$$
*UUZZ---5r}
E
EC99Xr	   c                 t    t          | t                    r"t          j        dk     rt	          | dd          } | S )N)   asciistrict)encodingerrors)
isinstancestrsysversion_infounicode)objs    r
   _to_unicoder3   O   s:    #s > 04 7 7cGH===Jr	   c                 t    t          j        t          |                                                     }||k    S )zExact matching of IP addresses.

    RFC 6125 explicitly doesn't define an algorithm for this
    (section 1.7.2 - "Out of Scope").
    )	ipaddress
ip_addressr3   rstrip)ipnamehost_ipips      r
   _ipaddress_matchr;   V   s2     
	k&1188::	;	;B=r	   c                    | st          d          	 t          j        t          |                    }n/# t          t           f$ r d}Y nt
          $ r t          d}n Y nw xY wg }|                     dd          }|D ]f\  }}|dk    r+|t          ||          r dS |                    |           6|dk    r*|t          ||          r dS |                    |           g|sP|                     dd          D ]9}|D ]4\  }}|dk    r)t          ||          r  dS |                    |           5:t          |          d	k    r;t          d
|dd                    t          t          |                              t          |          d	k    rt          d
|d|d                   t          d          )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
commonNamer   z	hostname z doesn't match either of z, z doesn't match r   z=no appropriate commonName or subjectAltName fields were found)
ValueErrorr5   r6   r3   UnicodeErrorAttributeErrorgetr&   r   r;   lenr   r   mapr   )certr   r9   dnsnamessankeyvaluesubs           r
   match_hostnamerM   b   sJ     
-
 
 	

&{8'<'<==*%   
    GG G H
((#R
(
(C # #
U%<<>%#B#BOOE""""L  "'7w'G'G"OOE""" 
+ 88Ir** 	+ 	+C! + +
U ,&&%eX66 OOE***+ 8}}q,4HHdiiD(@S@S6T6T6TV
 
 	
 
X!		8TU;;WXXXK
 
 	
s   !5 A!
A! A!)r   )__doc__r   r/   r5   ImportError__version__rA   r   r&   r3   r;   rM   r   r	   r
   <module>rQ      s    P P
 
			 



   III 	 	 	 	 	z 	 	 	3 3 3 3l  	 	 	=
 =
 =
 =
 =
s    