ó {G_Tc @s/dZddlZddlZddlmZmZmZddlmZddlmZmZm Z ddlm Z m Z m Z ddlm Z mZmZmZmZmZmZmZmZddlmZmZmZid e6d e6d e6Zydd lmZeZWnek r,eZn Xd eeR?R=tattrte((s/usr/local/lib/python2.7/ssl.pyR'ksF                   icCsQy|jj|ƒSWn6tk rL}|jdtkrF|jrFdS‚nXdS(sORead up to LEN bytes and return them. Return zero-length string on EOF.itN(R3treadRtargsRR?(RAtlentx((s/usr/local/lib/python2.7/ssl.pyRGŸs cCs|jj|ƒS(shWrite DATA to the underlying SSL channel. Returns number of bytes of DATA actually transmitted.(R3twrite(RAtdata((s/usr/local/lib/python2.7/ssl.pyRK¬scCs|jj|ƒS(sáReturns a formatted version of the data in the certificate provided by the other end of the SSL channel. Return None if no certificate was provided, {} if a certificate was provided, but not validated.(R3tpeer_certificate(RAt binary_form((s/usr/local/lib/python2.7/ssl.pyt getpeercert³scCs|js dS|jjƒSdS(N(R3R*tcipher(RA((s/usr/local/lib/python2.7/ssl.pyRP¼s icCs³|jrœ|dkr+td|jƒ‚nxtr˜y|jj|ƒ}WnDtk r}|jdtkrsdS|jdtkrŠdS‚q.X|Sq.Wn|j j ||ƒSdS(Nis3non-zero flags not allowed in calls to send() on %s( R3t ValueErrort __class__R4RKRRHR R R$tsend(RARLtflagstvRJ((s/usr/local/lib/python2.7/ssl.pyRSÃs     cCsX|jrtd|jƒ‚n5|dkr>|jj||ƒS|jj|||ƒSdS(Ns%sendto not allowed on instances of %s(R3RQRRR*R$tsendto(RARLt flags_or_addrtaddr((s/usr/local/lib/python2.7/ssl.pyRVØs   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(R3RQRRRIRSRtsendall(RARLRTtamounttcountRU((s/usr/local/lib/python2.7/ssl.pyRYás   cCsO|jr8|dkr+td|jƒ‚n|j|ƒS|jj||ƒSdS(Nis3non-zero flags not allowed in calls to recv() on %s(R3RQRRRGR$trecv(RAtbuflenRT((s/usr/local/lib/python2.7/ssl.pyR\ðs   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(R*RIR3RQRRRGR$t recv_into(RAtbuffertnbytesRTt tmp_bufferRU((s/usr/local/lib/python2.7/ssl.pyR^ús      cCs6|jrtd|jƒ‚n|jj||ƒSdS(Ns'recvfrom not allowed on instances of %s(R3RQRRR$trecvfrom(RAR]RT((s/usr/local/lib/python2.7/ssl.pyRb s cCs9|jrtd|jƒ‚n|jj|||ƒSdS(Ns,recvfrom_into not allowed on instances of %s(R3RQRRR$t recvfrom_into(RAR_R`RT((s/usr/local/lib/python2.7/ssl.pyRcs cCs|jr|jjƒSdSdS(Ni(R3tpending(RA((s/usr/local/lib/python2.7/ssl.pyRds  cCs?|jr%|jjƒ}d|_|Stdt|ƒƒ‚dS(NsNo SSL wrapper around (R3tshutdownR*RQtstr(RAts((s/usr/local/lib/python2.7/ssl.pytunwraps   cCsd|_tj||ƒdS(N(R*R3RRe(RAthow((s/usr/local/lib/python2.7/ssl.pyRe's cCs;|jdkr(d|_tj|ƒn|jd8_dS(Ni(R@R*R3Rtclose(RA((s/usr/local/lib/python2.7/ssl.pyRj+s cCs|jjƒdS(sPerform a TLS/SSL handshake.N(R3R7(RA((s/usr/local/lib/python2.7/ssl.pyR72sc 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!(R2RQR5R6R$R1R8R9R:R;R<R=R3Rt connect_exR*tconnectR>R7R4R.(RARXt return_errnotrc((s/usr/local/lib/python2.7/ssl.pyt _real_connect8s$       cCs|j|tƒdS(sQConnects to remote ADDR, and then wraps the connection in an SSL channel.N(RoR1(RARX((s/usr/local/lib/python2.7/ssl.pyRlOscCs|j|tƒS(sQConnects to remote ADDR, and then wraps the connection in an SSL channel.(RoR4(RARX((s/usr/local/lib/python2.7/ssl.pyRkTscCs¡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.R8R9RCR:R;R<R=R>R?N(RtacceptR#R8R9R4R:R;R<R=R>R?R.Rj(RAtnewsockRXRE((s/usr/local/lib/python2.7/ssl.pyRpYs            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.iRj(R@RR4(RAtmodetbufsize((s/usr/local/lib/python2.7/ssl.pytmakefilepsN(t__name__t __module__t__doc__R*R1RRR4R'RGRKRORPRSRVRYR\R^RbRcRdRhReRjR7RoRlRkRpRu(((s/usr/local/lib/python2.7/ssl.pyR#es60              c Cs@t|d|d|d|d|d|d|d|d|d | ƒ S( NR8R9RCR:R;R<R>R?R=(R#( RBR8R9RCR:R;R<R>R?R=((s/usr/local/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_timeRz((s/usr/local/lib/python2.7/ssl.pytcert_time_to_secondss 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(thasattrtbase64Rt PEM_HEADERttextwraptfillt PEM_FOOTERt encodestring(tder_cert_bytestf((s/usr/local/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( t startswithR‚RQtstriptendswithR…RIRt decodestring(tpem_cert_stringtd((s/usr/local/lib/python2.7/ssl.pytPEM_cert_to_DER_cert©s   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.R;R:R<N( R*RRRyRRlROR4RjR‰(RXR;R<thosttportR:Rgtdercert((s/usr/local/lib/python2.7/ssl.pytget_server_certificate·s     cCstj|dƒS(Ns (t_PROTOCOL_NAMEStget(t protocol_code((s/usr/local/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.R$iN( R€R$R5R6RRR*R-R.R7(RBR8R9tssl_sock((s/usr/local/lib/python2.7/ssl.pytsslwrap_simpleÐs    (7RxRƒR5RRRRRRRRRR R R R R RRRRRRRRR•RR+t ImportErrorR*RRRRR.Rt _getnameinfoR R!R"RR/R,R#R1R4RyR~R‚R…R‰RR”R˜Rš(((s/usr/local/lib/python2.7/ssl.pyt8sN  @      "  ÿ