ó -§Rc @sdZddlZddlZddlmZmZmZddlmZddlmZmZm Z ddlm Z m Z m Z ddlm Z mZmZmZmZmZmZmZmZddlmZmZmZid e6d e6d e6Zydd lmZeZWnek r,eZn Xd ee|jj||ƒS|jj|||ƒSdS(Ns%sendto not allowed on instances of %s(R.RLRMR%R!tsendto(R<RGt flags_or_addrtaddr((s"/opt/freeware/lib/python2.7/ssl.pyRQÓ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(R.RLRMRDRNRtsendall(R<RGROtamounttcountRP((s"/opt/freeware/lib/python2.7/ssl.pyRTÜs   cCsO|jr8|dkr+td|jƒ‚n|j|ƒS|jj||ƒSdS(Nis3non-zero flags not allowed in calls to recv() on %s(R.RLRMRBR!trecv(R<tbuflenRO((s"/opt/freeware/lib/python2.7/ssl.pyRWë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%RDR.RLRMRBR!t recv_into(R<tbuffertnbytesROt tmp_bufferRP((s"/opt/freeware/lib/python2.7/ssl.pyRYõs      cCs6|jrtd|jƒ‚n|jj||ƒSdS(Ns'recvfrom not allowed on instances of %s(R.RLRMR!trecvfrom(R<RXRO((s"/opt/freeware/lib/python2.7/ssl.pyR]s cCs9|jrtd|jƒ‚n|jj|||ƒSdS(Ns,recvfrom_into not allowed on instances of %s(R.RLRMR!t recvfrom_into(R<RZR[RO((s"/opt/freeware/lib/python2.7/ssl.pyR^ s cCs|jr|jjƒSdSdS(Ni(R.tpending(R<((s"/opt/freeware/lib/python2.7/ssl.pyR_s  cCs?|jr%|jjƒ}d|_|Stdt|ƒƒ‚dS(NsNo SSL wrapper around (R.tshutdownR%RLtstr(R<ts((s"/opt/freeware/lib/python2.7/ssl.pytunwraps   cCsd|_tj||ƒdS(N(R%R.RR`(R<thow((s"/opt/freeware/lib/python2.7/ssl.pyR`"s cCs;|jdkr(d|_tj|ƒn|jd8_dS(Ni(R;R%R.Rtclose(R<((s"/opt/freeware/lib/python2.7/ssl.pyRe&s cCs|jjƒdS(sPerform a TLS/SSL handshake.N(R.R2(R<((s"/opt/freeware/lib/python2.7/ssl.pyR2-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-RLR0R1R!R,R3R4R5R6R7R8R.Rt connect_exR%tconnectR9R2R/R)(R<RSt return_errnotrc((s"/opt/freeware/lib/python2.7/ssl.pyt _real_connect3s$       cCs|j|tƒdS(sQConnects to remote ADDR, and then wraps the connection in an SSL channel.N(RjR,(R<RS((s"/opt/freeware/lib/python2.7/ssl.pyRgJscCs|j|tƒS(sQConnects to remote ADDR, and then wraps the connection in an SSL channel.(RjR/(R<RS((s"/opt/freeware/lib/python2.7/ssl.pyRfOscCs¡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.R3R4R>R5R6R7R8R9R:N(RtacceptR R3R4R/R5R6R7R8R9R:R)Re(R<tnewsockRSR@((s"/opt/freeware/lib/python2.7/ssl.pyRkTs            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.iRe(R;RR/(R<tmodetbufsize((s"/opt/freeware/lib/python2.7/ssl.pytmakefileksN(t__name__t __module__t__doc__R%R,RRR/R"RBRFRJRKRNRQRTRWRYR]R^R_RcR`ReR2RjRgRfRkRp(((s"/opt/freeware/lib/python2.7/ssl.pyR ds6,              c Cs@t|d|d|d|d|d|d|d|d|d | ƒ S( NR3R4R>R5R6R7R9R:R8(R ( R=R3R4R>R5R6R7R9R:R8((s"/opt/freeware/lib/python2.7/ssl.pyt wrap_socketxs   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_timeRu((s"/opt/freeware/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(thasattrtbase64Rzt PEM_HEADERttextwraptfillt PEM_FOOTERt encodestring(tder_cert_bytestf((s"/opt/freeware/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}RLtstriptendswithR€RDR|t decodestring(tpem_cert_stringtd((s"/opt/freeware/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.R6R5R7N( R%RRRtRRgRJR/ReR„(RSR6R7thosttportR5Rbtdercert((s"/opt/freeware/lib/python2.7/ssl.pytget_server_certificate²s     cCstj|dƒS(Ns (t_PROTOCOL_NAMEStget(t protocol_code((s"/opt/freeware/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!R0R1RRR%R(R)R2(R=R3R4tssl_sock((s"/opt/freeware/lib/python2.7/ssl.pytsslwrap_simpleËs    (4RsR~R0RRRRRRRRRR R R R R RRRRRRRRRRR&t ImportErrorR%RRRRR)Rt _getnameinfoR|R*R'R R,R/RtRyR}R€R„R‹RR“R•(((s"/opt/freeware/lib/python2.7/ssl.pyt8sL  @      "  ÿ