ó Eu\dc@sdZddlZddlZyddlZWnek rGdZnXdZdefd„ƒYZdd„Z d„Z d „Z d „Z dS( sJThe match_hostname() function from Python 3.3.3, essential when using SSL.iÿÿÿÿNs3.5.0.1tCertificateErrorcBseZRS((t__name__t __module__(((sx/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/util/ssl_match_hostname.pyRsic CsRg}|stS|jdƒ}|d}|d}|jdƒ}||krgtdt|ƒƒ‚n|sƒ|jƒ|jƒkS|dkrŸ|jdƒnY|jdƒs½|jdƒrÖ|jtj |ƒƒn"|jtj |ƒj dd ƒƒx$|D]}|jtj |ƒƒqÿWtj d d j |ƒd tj ƒ} | j|ƒS( shMatching according to RFC 6125, section 6.4.3 http://tools.ietf.org/html/rfc6125#section-6.4.3 t.iit*s,too many wildcards in certificate DNS name: s[^.]+sxn--s\*s[^.]*s\As\.s\Z(tFalsetsplittcountRtreprtlowertappendt startswithtretescapetreplacetcompiletjoint IGNORECASEtmatch( tdnthostnamet max_wildcardstpatstpartstleftmostt remaindert wildcardstfragtpat((sx/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/util/ssl_match_hostname.pyt_dnsname_matchs*    " &cCs=t|tƒr9tjdkr9t|ddddƒ}n|S(Nitencodingtasciiterrorststrict(i(t isinstancetstrtsyst version_infotunicode(tobj((sx/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/util/ssl_match_hostname.pyt _to_unicodeOscCs%tjt|ƒjƒƒ}||kS(sˆExact matching of IP addresses. RFC 6125 explicitly doesn't define an algorithm for this (section 1.7.2 - "Out of Scope"). (t ipaddresst ip_addressR(trstrip(tipnamethost_iptip((sx/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/util/ssl_match_hostname.pyt_ipaddress_matchVscCs|stdƒ‚nytjt|ƒƒ}WnEttfk rMd}n)tk rutdkrod}qv‚nXg}|jddƒ}xŠ|D]‚\}}|dkrÜ|dkrÌt||ƒrÌdS|j |ƒq•|dkr•|dk rt ||ƒrdS|j |ƒq•q•W|s‡xc|jddƒD]L}xC|D];\}}|dkrAt||ƒrldS|j |ƒqAqAWq4Wnt |ƒdkrÄt d |d j tt|ƒƒfƒ‚n;t |ƒdkrót d ||d fƒ‚n t d ƒ‚dS(s)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. stempty or no certificate, match_hostname needs a SSL socket or SSL context with either CERT_OPTIONAL or CERT_REQUIREDtsubjectAltNametDNSNs IP Addresstsubjectt commonNameis&hostname %r doesn't match either of %ss, shostname %r doesn't match %ris=no appropriate commonName or subjectAltName fields were found(((t ValueErrorR)R*R(t UnicodeErrortNonetAttributeErrortgetRR R/tlenRRtmapR(tcertRR-tdnsnamestsantkeytvaluetsub((sx/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/util/ssl_match_hostname.pytmatch_hostnamebsJ        %( t__doc__R R$R)t ImportErrorR6t __version__R4RRR(R/RA(((sx/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/util/ssl_match_hostname.pyts     6