Ժh/zdZddlZddlZ ddlZn #e$rdZYnwxYwdZGddeZd dZdZ d Z d Z dS) zJThe match_hostname() function from Python 3.3.3, essential when using SSL.Nz3.5.0.1ceZdZdS)CertificateErrorN)__name__ __module__ __qualname__j/opt/imunify360/venv/lib64/python3.11/site-packages/urllib3/packages/ssl_match_hostname/_implementation.pyrrsDr rclg}|sdS|d}|d}|dd}|d}||krtdt|z|s*||kS|dkr|dn|d s|d r(|tj|n;|tj| d d |D])}|tj|*tj d d |zdztj } | |S)zhMatching according to RFC 6125, section 6.4.3 http://tools.ietf.org/html/rfc6125#section-6.4.3 F.rr N*z,too many wildcards in certificate DNS name: z[^.]+zxn--z\*z[^.]*z\Az\.z\Z)splitcountrreprlowerappend startswithreescapereplacecompilejoin IGNORECASEmatch) dnhostname max_wildcardspatspartsleftmost remainder wildcardsfragpats r _dnsname_matchr&s D u HHTNNEQxHabb Is##I=   :T"XX E   .xxzzX^^---- 3 G   V $ $A(;(;F(C(CA BIh''(((( BIh''//w??@@@%% BIdOO$$$$ *UUZZ---5r} E EC 99X  r ctt|tr"tjdkrt |dd}|S)N)asciistrict)encodingerrors) isinstancestrsys version_infounicode)objs r _to_unicoder3Os:#s> 04 7 7cGH=== Jr cttjt|}||kS)zExact matching of IP addresses. RFC 6125 explicitly doesn't define an algorithm for this (section 1.7.2 - "Out of Scope"). ) ipaddress ip_addressr3rstrip)ipnamehost_ipips r _ipaddress_matchr;Us2  k&1188:: ; ;B =r c |std tjt|}n5#t$rd}Yn't$rd}Ynt $rtd}nYnwxYwg}|dd}|D]f\}}|dkr+|t||rdS||6|dkr*|t||rdS||g|sP|ddD]9}|D]4\}}|dkr)t||rdS||5:t|d kr;td |d d tt|t|d krtd |d |dtd)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_REQUIREDNsubjectAltNamerDNSz IP Addresssubject commonNamer z hostname z doesn't match either of z, z doesn't match rz=no appropriate commonName or subjectAltName fields were found) ValueErrorr5r6r3 UnicodeErrorAttributeErrorgetr&rr;lenrrmapr)certrr9dnsnamessankeyvaluesubs r match_hostnamerMas`   -   &{8'<'<==     GG  G H ((#R ( (C## U %<<>%#B#B OOE " " " " L "'7w'G'G" OOE " " "  +88Ir** + +C! + + U,&&%eX66OOE***  + 8}}q,4HHdiiD(@S@S6T6T6T V    X!  8TU;;WXXX K   s!5 A' A'A'&A')r ) __doc__rr/r5 ImportError __version__rArr&r3r;rMrr r rQsPP  III      z   3333l   ? ? ? ? ? s