ó CØê[c @sfdZddlZddlZddlZddlmZmZmZddlmZddlmZm Z m Z ddlm Z m Z m Z ddlmZmZmZmZmZmZmZmZmZddlmZmZmZid e6d e6d e6Zydd lmZeZWnek r8eZn Xd ee|jj||ƒS|jj|||ƒSdS(Ns%sendto not allowed on instances of %s(R_RER|RWRQtsendto(RmRwt flags_or_addrtaddr((s/usr/lib/python2.7/ssl.pyR€7s   cCsˆ|jrq|dkr+td|jƒ‚nt|ƒ}d}x-||krl|j||ƒ}||7}q@W|Stj|||ƒSdS(Nis6non-zero flags not allowed in calls to sendall() on %s(R_RER|RGR}Rtsendall(RmRwR~tamountR*R((s/usr/lib/python2.7/ssl.pyRƒ@s   cCsO|jr8|dkr+td|jƒ‚n|j|ƒS|jj||ƒSdS(Nis3non-zero flags not allowed in calls to recv() on %s(R_RER|RsRQtrecv(RmtbuflenR~((s/usr/lib/python2.7/ssl.pyR…Os   cCs¤|r!|dkr!t|ƒ}n|dkr6d}n|jrŠ|dkratd|jƒ‚n|j|ƒ}t|ƒ}|||*|S|jj|||ƒSdS(Niis8non-zero flags not allowed in calls to recv_into() on %s(RWRGR_RER|RsRQt recv_into(RmtbuffertnbytesR~t tmp_bufferR((s/usr/lib/python2.7/ssl.pyR‡Ys      cCs6|jrtd|jƒ‚n|jj||ƒSdS(Ns'recvfrom not allowed on instances of %s(R_RER|RQtrecvfrom(RmR†R~((s/usr/lib/python2.7/ssl.pyR‹js cCs9|jrtd|jƒ‚n|jj|||ƒSdS(Ns,recvfrom_into not allowed on instances of %s(R_RER|RQt recvfrom_into(RmRˆR‰R~((s/usr/lib/python2.7/ssl.pyRŒqs cCs|jr|jjƒSdSdS(Ni(R_tpending(Rm((s/usr/lib/python2.7/ssl.pyRxs  cCs?|jr%|jjƒ}d|_|Stdt|ƒƒ‚dS(NsNo SSL wrapper around (R_tshutdownRWREtstr(Rmts((s/usr/lib/python2.7/ssl.pytunwrap~s   cCsd|_tj||ƒdS(N(RWR_RRŽ(Rmthow((s/usr/lib/python2.7/ssl.pyRŽ†s cCs;|jdkr(d|_tj|ƒn|jd8_dS(Ni(RlRWR_Rtclose(Rm((s/usr/lib/python2.7/ssl.pyR“Šs cCs|jjƒdS(sPerform a TLS/SSL handshake.N(R_Rc(Rm((s/usr/lib/python2.7/ssl.pyRc‘sc CsÙ|jrtdƒ‚ntj|jt|j|j|j|j |j |j ƒ|_ ya|rrt j||ƒ}nd}t j||ƒ|s°|jr¤|jƒnt|_n|SWntk rÔd|_ ‚nXdS(Ns/attempt to connect already-connected SSLSocket!(R^RERaRbRQR(RdReRfRgRhRiR_Rt connect_exRWtconnectRjRcR`R[(RmR‚t return_errnotrc((s/usr/lib/python2.7/ssl.pyt _real_connect—s$       cCs|j|tƒdS(sQConnects to remote ADDR, and then wraps the connection in an SSL channel.N(R˜R((RmR‚((s/usr/lib/python2.7/ssl.pyR•®scCs|j|tƒS(sQConnects to remote ADDR, and then wraps the connection in an SSL channel.(R˜R`(RmR‚((s/usr/lib/python2.7/ssl.pyR”³scCs¡tj|ƒ\}}ybt|d|jd|jdtd|jd|jd|jd|j d|j d |j ƒ |fSWn#t k rœ}|j ƒ|‚nXd S( s¿Accepts a new connection from a remote client, and returns a tuple containing that new connection wrapped with a server-side SSL channel, and the address of the remote client.RdReRoRfRgRhRiRjRkN(RtacceptRPRdReR`RfRgRhRiRjRkR[R“(RmtnewsockR‚Rq((s/usr/lib/python2.7/ssl.pyR™¸s            triÿÿÿÿcCs%|jd7_t|||dtƒS(sMake and return a file-like object that works with the SSL connection. Just use the code from the socket module.iR“(RlRR`(Rmtmodetbufsize((s/usr/lib/python2.7/ssl.pytmakefileÏsN(R$R%t__doc__RWR(RRR`RTRsRvRzR{R}R€RƒR…R‡R‹RŒRR‘RŽR“RcR˜R•R”R™Rž(((s/usr/lib/python2.7/ssl.pyRPÄs60              c Cs@t|d|d|d|d|d|d|d|d|d | ƒ S( NRdReRoRfRgRhRjRkRi(RP( RnRdReRoRfRgRhRjRkRi((s/usr/lib/python2.7/ssl.pyt wrap_socketÜs   cCs%ddl}|j|j|dƒƒS(s¢Takes a date-time string in standard ASN1_print form ("MON DAY 24HOUR:MINUTE:SEC YEAR TIMEZONE") and return a Python time value in seconds past the epoch.iÿÿÿÿNs%b %d %H:%M:%S %Y GMT(ttimetmktimetstrptime(t cert_timeR¡((s/usr/lib/python2.7/ssl.pytcert_time_to_secondsìs s-----BEGIN CERTIFICATE-----s-----END CERTIFICATE-----cCscttdƒrBtj|ƒ}tdtj|dƒdtdStdtj|ƒtdSdS(s[Takes a certificate in binary DER format and returns the PEM version of it as a string.tstandard_b64encodes i@N(thasattrtbase64R¦t PEM_HEADERttextwraptfillt PEM_FOOTERt encodestring(tder_cert_bytestf((s/usr/lib/python2.7/ssl.pytDER_cert_to_PEM_certøs$cCsw|jtƒs"tdtƒ‚n|jƒjtƒsJtdtƒ‚n|jƒttƒttƒ !}tj|ƒS(shTakes a certificate in ASCII PEM format and returns the DER-encoded version of it as a byte sequences(Invalid PEM encoding; must start with %ss&Invalid PEM encoding; must end with %s( R.R©REtstriptendswithR¬RGR¨t decodestring(tpem_cert_stringtd((s/usr/lib/python2.7/ssl.pytPEM_cert_to_DER_certs   cCsx|\}}|dk r!t}nt}ttƒd|d|d|ƒ}|j|ƒ|jtƒ}|jƒt |ƒS(s÷Retrieve the certificate from the server at the specified address, and return it as a PEM-encoded string. If 'ca_certs' is specified, validate the server cert against it. If 'ssl_version' is specified, use it in the connection attempt.RgRfRhN( RWRRR RR•RzR`R“R°(R‚RgRhthosttportRfRtdercert((s/usr/lib/python2.7/ssl.pytget_server_certificates     cCstj|dƒS(Ns (t_PROTOCOL_NAMESRF(t protocol_code((s/usr/lib/python2.7/ssl.pytget_protocol_name)scCslt|dƒr|j}ntj|d||ttdƒ}y|jƒWntk r]n X|j ƒ|S(sŒA replacement for the old socket.ssl function. Designed for compability with Python 2.5 and earlier. Will disappear in Python 3.0.RQiN( R§RQRaRbRRRWRZR[Rc(RnRdRetssl_sock((s/usr/lib/python2.7/ssl.pytsslwrap_simple/s    (<RŸRªR/RaRRRRRRRRRR R R R R RRRRRRRRR»RRXt ImportErrorRWRRRRR[Rt _getnameinfoR R!R"R¨R\RYRER#R@RORPR(R`R R¥R©R¬R°R¶RºR½R¿(((s/usr/lib/python2.7/ssl.pyt8sV   @      "   3 (ÿ