ó b@RTc@s ddlmZmZddlmZmZddlmZyXdZ e Z ddl Z ddl m Z mZmZddl m Z ddl m Z Wnek r§nXd „Zd „Zd „Ze dk ríddddddd „Znddddddd „ZdS(iÿÿÿÿ(thexlifyt unhexlify(tmd5tsha1i(tSSLErrorN(t wrap_sockett CERT_NONEtPROTOCOL_SSLv23(t SSLContext(tHAS_SNIcCsÍitd6td6}|jddƒjƒ}tt|ƒdƒ\}}|sY||krhtdƒ‚nt|jƒƒ}||}||ƒj ƒ}||ksÉtdj t |ƒt |ƒƒƒ‚ndS( sá Checks if given fingerprint matches the supplied certificate. :param cert: Certificate as bytes object. :param fingerprint: Fingerprint as string of hexdigits, can be interspersed by colons. iit:tis!Fingerprint is of invalid length.s6Fingerprints did not match. Expected "{0}", got "{1}".N( RRtreplacetlowertdivmodtlenRRtencodetdigesttformatR(tcertt fingerprintt hashfunc_mapt digest_lengthtoddtfingerprint_bytesthashfunct cert_digest((sP/opt/freeware/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.pytassert_fingerprints      cCs[|dkrtSt|tƒrWtt|dƒ}|dkrSttd|ƒ}n|S|S(sæ Resolves the argument to a numeric constant, which can be passed to the wrap_socket function/method from the ssl module. Defaults to :data:`ssl.CERT_NONE`. If given a string it is assumed to be the name of the constant in the :mod:`ssl` module or its abbrevation. (So you can specify `REQUIRED` instead of `CERT_REQUIRED`. If it's neither `None` nor a string we assume it is already the numeric constant which can directly be passed to wrap_socket. tCERT_N(tNoneRt isinstancetstrtgetattrtssl(t candidatetres((sP/opt/freeware/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.pytresolve_cert_reqs7s  cCs[|dkrtSt|tƒrWtt|dƒ}|dkrSttd|ƒ}n|S|S(s like resolve_cert_reqs t PROTOCOL_N(RRRRR R!(R"R#((sP/opt/freeware/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.pytresolve_ssl_versionNs  c Cs¥t|ƒ}||_d}|j|O_|rfy|j|ƒWqftk rb} t| ƒ‚qfXn|r|j||ƒntr˜|j|d|ƒS|j|ƒS(sÇ All arguments except `server_hostname` have the same meaning as for :func:`ssl.wrap_socket` :param server_hostname: Hostname of the expected certificate itserver_hostname( Rt verify_modetoptionstload_verify_locationst ExceptionRtload_cert_chainR R( tsocktkeyfiletcertfilet cert_reqstca_certsR't ssl_versiontcontexttOP_NO_COMPRESSIONte((sP/opt/freeware/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.pytssl_wrap_socket_s  c Cs(t|d|d|d|d|d|ƒS(NR.R/R1R0R2(R(R-R.R/R0R1R'R2((sP/opt/freeware/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.pyR6s (tbinasciiRRthashlibRRt exceptionsRRRtFalseR R!RRRt ImportErrorRR$R&R6(((sP/opt/freeware/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.pyts*   $