î j fbc ã @ s d d l Z d d l Z y d d l Z Wn e k rB d Z Yn Xd d l m Z d d l m Z d d l m Z d d l m Z d d „ Z d d „ Z d Z d Z d Z d Z Gd d „ d e ƒ Z Gd d „ d e j e j ƒ Z Gd d „ d e j ƒ Z d S)é Né )Úcompat)Ú protocols)Ú transports)Úloggerc C s• | r t d ƒ ‚ n t t d ƒ rE t j ƒ } | s‘ d | _ q‘ nL t j t j ƒ } | j t j O_ | j t j O_ | j ƒ t j | _ | S)Nz(Server side SSL needs a valid SSLContextÚcreate_default_contextF) Ú ValueErrorÚhasattrÚsslr Úcheck_hostnameZ SSLContextZPROTOCOL_SSLv23ZoptionsZOP_NO_SSLv2ZOP_NO_SSLv3Zset_default_verify_pathsZ CERT_REQUIREDÚverify_mode)Úserver_sideÚserver_hostnameÚ sslcontext© r ú5/opt/alt/python34/lib64/python3.4/asyncio/sslproto.pyÚ_create_transport_context s r c C s t t d ƒ S)NÚ MemoryBIO)r r r r r r Ú_is_sslproto_available$ s r Z UNWRAPPEDZDO_HANDSHAKEZWRAPPEDZSHUTDOWNc @ s» e Z d Z d Z d Z d d d „ Z e d d „ ƒ Z e d d „ ƒ Z e d d „ ƒ Z e d d „ ƒ Z d d d „ Z d d d „ Z d d „ Z d d d „ Z d d d „ Z d S)Ú_SSLPipea An SSL "Pipe". An SSL pipe allows you to communicate with an SSL/TLS protocol instance through memory buffers. It can be used to implement a security layer for an existing connection where you don't have access to the connection's file descriptor, or for some reason you don't want to use it. An SSL pipe can be in "wrapped" and "unwrapped" mode. In unwrapped mode, data is passed through untransformed. In wrapped mode, application level data is encrypted to SSL record level data and vice versa. The SSL record level is the lowest level in the SSL protocol suite and is what travels as-is over the wire. An SslPipe initially is in "unwrapped" mode. To start SSL, call do_handshake(). To shutdown SSL again, call unwrap(). é i Nc C sj | | _ | | _ | | _ t | _ t j ƒ | _ t j ƒ | _ d | _ d | _ d | _ d | _ d S)a• The *context* argument specifies the ssl.SSLContext to use. The *server_side* argument indicates whether this is a server side or client side transport. The optional *server_hostname* argument can be used to specify the hostname you are connecting to. You may only specify this parameter if the _ssl module supports Server Name Indication (SNI). NF) Ú_contextÚ_server_sideÚ_server_hostnameÚ _UNWRAPPEDÚ_stater r Ú _incomingÚ _outgoingÚ_sslobjÚ _need_ssldataÚ _handshake_cbÚ_shutdown_cb)ÚselfÚcontextr r r r r Ú__init__C s z_SSLPipe.__init__c C s | j S)z*The SSL context passed to the constructor.)r )r" r r r r# Y s z_SSLPipe.contextc C s | j S)z^The internal ssl.SSLObject instance. Return None if the pipe is not wrapped. )r )r" r r r Ú ssl_object^ s z_SSLPipe.ssl_objectc C s | j S)zgWhether more record level data is needed to complete a handshake that is currently in progress.)r )r" r r r Úneed_ssldataf s z_SSLPipe.need_ssldatac C s | j t k S)zj Whether a security layer is currently in effect. Return False during handshake. )r Ú_WRAPPED)r" r r r Úwrappedl s z_SSLPipe.wrappedc C s— | j t k r t d ƒ ‚ n | j j | j | j d | j d | j ƒ| _ t | _ | | _ | j d d d ƒ\ } } t | ƒ d k s“ t ‚ | S)aL Start the SSL handshake. Return a list of ssldata. A ssldata element is a list of buffers The optional *callback* argument can be used to install a callback that will be called when the handshake is complete. The callback will be called with None if successful, else an exception instance. z"handshake in progress or completedr r ó Úonly_handshakeTr )r r ÚRuntimeErrorr Zwrap_bior r r r r Ú _DO_HANDSHAKEr Úfeed_ssldataÚlenÚAssertionError)r" ÚcallbackÚssldataÚappdatar r r Údo_handshakeu s z_SSLPipe.do_handshakec C s£ | j t k r t d ƒ ‚ n | j t k r<