usr/lib/python2.7/site-packages/setuptools/ssl_support.pyo000064400000020504147205136560017774 0ustar00 fc@s/ddlZddlZddlZddlZddlZddlmZmZmZm Z ddl m Z m Z yddl Z Wnek rdZ nXdddddgZd jjZyejjZejZWnek reZZnXe dk oeeefkZydd l mZmZWnUek ry$dd lmZdd lmZWqek rdZdZqXnXesd efdYZnesddZdZndefdYZdefdYZ ddZ!dZ"e"dZ#dZ$dZ%dS(iN(turllibt http_clienttmaptfilter(tResolutionErrortExtractionErrortVerifyingHTTPSHandlertfind_ca_bundlet is_availablet cert_pathst opener_fors /etc/pki/tls/certs/ca-bundle.crt /etc/ssl/certs/ca-certificates.crt /usr/share/ssl/certs/ca-bundle.crt /usr/local/share/certs/ca-root.crt /etc/ssl/cert.pem /System/Library/OpenSSL/certs/cert.pem /usr/local/share/certs/ca-root-nss.crt /etc/ssl/ca-bundle.pem (tCertificateErrortmatch_hostname(R (R R cBseZRS((t__name__t __module__(((s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pyR 5sic CsRg}|stS|jd}|d}|d}|jd}||krgtdt|n|s|j|jkS|dkr|jdnY|jds|jdr|jtj |n"|jtj |j dd x$|D]}|jtj |qWtj d d j |d tj } | j|S( spMatching 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(tFalsetsplittcountR treprtlowertappendt startswithtretescapetreplacetcompiletjoint IGNORECASEtmatch( tdnthostnamet max_wildcardstpatstpartstleftmostt remaindert wildcardstfragtpat((s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pyt_dnsname_match;s*    " &cCs[|stdng}|jdd }xC|D];\}}|dkr4t||r_dS|j|q4q4W|sxc|jddD]L}xC|D];\}}|dkrt||rdS|j|qqWqWnt|dkrtd|d jtt|fn;t|dkrKtd ||d fn td 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. sempty or no certificatetsubjectAltNametDNSNtsubjectt commonNameis&hostname %r doesn't match either of %ss, shostname %r doesn't match %ris=no appropriate commonName or subjectAltName fields were found((( t ValueErrortgetR)RtlenR RRR(tcertR tdnsnamestsantkeytvaluetsub((s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pyR os.  %cBs eZdZdZdZRS(s=Simple verifying handler: no auth, subclasses, timeouts, etc.cCs||_tj|dS(N(t ca_bundlet HTTPSHandlert__init__(tselfR7((s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pyR9s csjfd|S(Ncst|j|S(N(tVerifyingHTTPSConnR7(thosttkw(R:(s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pytt(tdo_open(R:treq((R:s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pyt https_opens(R Rt__doc__R9RB(((s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pyRs R;cBs eZdZdZdZRS(s@Simple verifying connection: no auth, subclasses, timeouts, etc.cKs tj|||||_dS(N(tHTTPSConnectionR9R7(R:R<R7R=((s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pyR9scCs+tj|j|jft|dd}t|drjt|ddrj||_|j|j }n |j}tt drt j d|j }|j |d||_n$t j |dt jd|j |_yt|jj|Wn4tk r&|jjtj|jjnXdS( Ntsource_addresst_tunnelt _tunnel_hosttcreate_default_contexttcafiletserver_hostnamet cert_reqstca_certs(tsockettcreate_connectionR<tporttgetattrtNonethasattrtsockRFRGtsslRHR7t wrap_sockett CERT_REQUIREDR t getpeercertR tshutdownt SHUT_RDWRtclose(R:RSt actual_hosttctx((s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pytconnects$$!      (R RRCR9R](((s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pyR;s cCs"tjjt|ptjS(s@Get a urlopen() replacement that uses ca_bundle for verification(Rtrequestt build_openerRRtopen(R7((s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pyR s cs"tjfd}|S(Ncs+tds$||_njS(Ntalways_returns(RRRa(targstkwargs(tfunc(s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pytwrappers(t functoolstwraps(RdRe((Rds:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pytoncescsnyddl}Wntk r$dSXd|jffdY}|jd|jd|jS(NitCertFilecs&eZfdZfdZRS(cs't|jtj|jdS(N(tsuperR9tatexittregisterRZ(R:(Ri(s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pyR9scs/yt|jWntk r*nXdS(N(RjRZtOSError(R:(Ri(s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pyRZs (R RR9RZ((Ri(s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pyRistCAtROOT(t wincertstoret ImportErrorRQRitaddstoretname(Rpt _wincerts((Ris:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pytget_win_certfiles    cCs4ttjjt}tp3t|dp3tS(s*Return an existing CA bundle path, or NoneN( RtostpathtisfileR RutnextRQt_certifi_where(textant_cert_paths((s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pyRs cCs5ytdjSWntttfk r0nXdS(Ntcertifi(t __import__twhereRqRR(((s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pyRzs(&RvRMRkRRftsetuptools.extern.six.movesRRRRt pkg_resourcesRRRTRqRQt__all__tstripRR R^R8RDtAttributeErrortobjectRR R tbackports.ssl_match_hostnameR.R)RR;R RhRuRRz(((s:/usr/lib/python2.7/site-packages/setuptools/ssl_support.pytsP     "          4 ) (