
    iԇ              	          d Z ddlmZ ddlZej        ZddlZddlmZm	Z	 ddlm
Z ddlmZ eZddlmZ g dZ eed	          re                    d	           g Znd	gZdd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddlm!Z! ddlm"Z" ddlm#Z# ddlm$Z$ ddlm%Z% ddlm&Z& ddlm'Z' ddlm(Z(  ee e)            edgz   d          Z*ee*z   ez   Z+de+v re+,                    d           ej-        Z. G d  d!ej/                  Z0 G d" d#e1          Z2 G d$ d%e.          Z- G d& d'e          Z3e3e-_4         ed(          Z5 ed)          Z6 ed*          Z7ddd+ee$dd,d,df	d-Z8e$dfd.Z9dS )/zSSL wrapper for socket objects on Python 3.

For the documentation, refer to :mod:`ssl` module manual.

This module implements cooperative SSL socket wrappers.
    )absolute_importN)sockettimeout_default)timeout)copy_globals)ref)
SSLContext	SSLSocketget_server_certificatewrap_socket)AF_INET)SOCK_STREAM)SO_TYPE)
SOL_SOCKET)SSLWantReadError)SSLWantWriteError)SSLEOFError)SSLZeroReturnError)	CERT_NONE)SSLError)SSL_ERROR_EOF)SSL_ERROR_WANT_READ)SSL_ERROR_WANT_WRITE)PROTOCOL_SSLv23)CHANNEL_BINDING_TYPES)CERT_REQUIRED)DER_cert_to_PEM_cert)create_connectionr    )names_to_ignoredunder_names_to_keep
namedtuplec                   "     e Zd ZdZ fdZ xZS )_contextawaresock)_sslsockc                 ^    t                                          ||||           || _        d S N)super__init__r%   )selffamilytypeprotofilenosslsocket_wref	__class__s         5/usr/local/lib/python3.11/dist-packages/gevent/ssl.pyr)   z_contextawaresock.__init__[   s,    uf555&    )__name__
__module____qualname__	__slots__r)   __classcell__r0   s   @r1   r$   r$   X   s=        I' ' ' ' ' ' ' ' 'r2   r$   c                       e Zd ZdZd Zd ZdS )	_Callbackuser_functionc                     || _         d S r'   r;   )r*   r<   s     r1   r)   z_Callback.__init__d   s    *r2   c                 F    |                                 } | j        |g|R  S r'   )r%   r<   )r*   connargss      r1   __call__z_Callback.__call__g   s*    }}!t!$.....r2   N)r3   r4   r5   r6   r)   rA   r   r2   r1   r:   r:   `   s7        "I+ + +/ / / / /r2   r:   c                       e Zd ZdZdZ	 	 	 	 	 ddZ eej        d          rEej        j	         fd            Zej
        j	         fd            Z
ej        j	         fd	            Z eed
          r.ej        j	         fd            Zej        j	         fd            Z eed          re fd            Zej	         fd            Z eed          r#e fd            Zej	         fd            Z xZS  fdZ xZS )r	   r   NFTc           	      :    |                      |||||| |          S )N)sockserver_sidedo_handshake_on_connectsuppress_ragged_eofsserver_hostname_context_session)sslsocket_class)r*   rD   rE   rF   rG   rH   sessions          r1   r   zSSLContext.wrap_socketr   s5     ##;$;!5+ $   	r2   setterc                 n    t          t          t                    j                            | |           d S r'   )r(   orig_SSLContextoptions__set__r*   valuer0   s     r1   rP   zSSLContext.options   s,    /?33;CCD%PPPPPr2   c                 n    t          t          t                    j                            | |           d S r'   )r(   rO   verify_flagsrQ   rR   s     r1   rU   zSSLContext.verify_flags   s,    /?33@HHuUUUUUr2   c                 n    t          t          t                    j                            | |           d S r'   )r(   rO   verify_moderQ   rR   s     r1   rW   zSSLContext.verify_mode   s,    /?33?GGeTTTTTr2   minimum_versionc                 n    t          t          t                    j                            | |           d S r'   )r(   rO   rX   rQ   rR   s     r1   rX   zSSLContext.minimum_version   -    /?33CKKDRWXXXXXr2   c                 n    t          t          t                    j                            | |           d S r'   )r(   rO   maximum_versionrQ   rR   s     r1   r\   zSSLContext.maximum_version   rZ   r2   _msg_callbackc                 f    t                      j        }t          |t                    r|j        }|S r'   )r(   r]   
isinstancer:   r<   r*   resultr0   s     r1   r]   zSSLContext._msg_callback   s.    WW*F&),, .-Mr2   c                     |rt          |          rt          |          }t          t          _        	 t          t          t                    j                            | |           t          t          _        d S # t          t          _        w xY wr'   )callabler:   rO   __ssl__r	   r(   r]   rQ   rR   s     r1   r]   zSSLContext._msg_callback   sw     )% )!%((!0G0j*--;CCD%PPP%/"""Z"////s   3A: :Bsni_callbackc                 f    t                      j        }t          |t                    r|j        }|S r'   )r(   re   r_   r:   r<   r`   s     r1   re   zSSLContext.sni_callback   s.    WW)F&),, .-Mr2   c                     |rt          |          rt          |          }t          t          t                    j                            | |           d S r'   )rc   r:   r(   rO   re   rQ   rR   s     r1   re   zSSLContext.sni_callback   sN     )% )!%((/?33@HHuUUUUUr2   c                     |rt          |          rt          |          }t                                          |           d S r'   )rc   r:   r(   set_servername_callback)r*   server_name_callbackr0   s     r1   ri   z"SSLContext.set_servername_callback   sK    # G1E(F(F G'01E'F'F$GG++,@AAAAAr2   )FTTNN)r3   r4   r5   r6   rK   r   hasattrrO   rP   rM   rU   rW   rX   r\   propertyr]   re   ri   r7   r8   s   @r1   r	   r	   k   s{       I O,1,0)-$( 	     w&11 U 
	 	'	Q 	Q 	Q 	Q 
(	'	Q 
	%	,	V 	V 	V 	V 
-	,	V 
	$	+	U 	U 	U 	U 
,	+	U w 122 	Y 
	(	/	Y 	Y 	Y 	Y 
0	/	Y 
	(	/	Y 	Y 	Y 	Y 
0	/	Y w00 0 
	 	 	 	 
	 
		0 	0 	0 	0 
		0 w// B		 	 	 	 
	
 
		V 	V 	V 	V 
		V 	V 	V 	V 	V	B 	B 	B 	B 	B 	B 	B 	B 	Br2   r	   c                       e Zd ZdZddddeeddeeddddddddfdZd Z	d Z
ed	             Zej        d
             Zed             Zej        d             Zed             Zd Zd7dZd Zd8dZd Zd9dZd Z eed          r	d Zd Zd Zd Zd ZdefdZd7dZ d Z!d:dZ"d;d!Z#d<d"Z$d;d#Z%d<d$Z&d% Z'd& Z(d' Z)d( Z*d) Z+d* Z,d+ Z-d=d,Z.d- Z/d. Z0d/ Z1 fd0Z2d>d2Z3d3 Z4 ee5j6        d4          r
d5 Z7d6 Z8 xZ9S  xZ9S )?r
   zp
    gevent `ssl.SSLSocket
    <https://docs.python.org/3/library/ssl.html#ssl-sockets>`_ for
    Python 3.
    NFTr   c                 *   |r|| _         n|r|st          d          |r|st          d          |r|s|}t          |          | _         || j         _        |r| j                             |           |r| j                             ||           |r| j                             |           |r| j                             |           || _        || _	        || _
        || _        || _        || _        |                    t          t                     t"          k    rt%          d          |r"|rt          d          |t          d          | j         j        r|st          d          || _        || _        || _        || _        || _        d}d }|c|                                }t5          j        | |j        |j        |j        |                                           |                                  n1|t5          j        | |	           nt5          j        | |	|
|
           d| _!        d | _"        	 | j#        $                                 d}n# tJ          $ r}|j&        tL          j'        k    r| (                                  | )                                }| *                    d           	 | +                    d          }n9# tJ          $ r,}|j&        tL          j'        tL          j,        fvr d}Y d }~nd }~ww xY w| *                    |           |rMd}t[          |j&        |          }||_.        d |_/        	 | (                                 n# tJ          $ r Y nw xY w|Y d }~nd }~ww xY w| 0                    |           || _1        |r	 | 2                    ||          | _"        |r?|                                 }|dk    rt          d          | 3                                 d S d S # tJ          $ r | (                                  w xY wd S )Nz5certfile must be specified for server-side operationszcertfile must be specifiedz!only stream sockets are supportedz4server_hostname can only be specified in client modez,session can only be specified in client modez'check_hostname requires server_hostnameF)r+   r,   r-   r.   )r.   )r+   r,   r-   T   r2   z5Closed before TLS handshake with data in recv buffer.        zHdo_handshake_on_connect should not be specified for non-blocking sockets)4rI   
ValueErrorr	   rW   load_verify_locationsload_cert_chainset_npn_protocolsset_cipherskeyfilecertfile	cert_reqsssl_versionca_certsciphers
getsockoptr   r   r   NotImplementedErrorcheck_hostnamerJ   rE   rH   rF   rG   
gettimeoutr   r)   r+   r,   r-   r.   detach_closed_sslobj_sockgetpeernameOSErrorerrnoENOTCONNclosegetblockingsetblockingrecvEINVALr   reasonlibrary
settimeout
_connected_SSLSocket__create_sslobjdo_handshake)r*   rD   rv   rw   rE   rx   ry   rz   rF   r+   r,   r-   r.   rG   npn_protocolsr{   rH   rJ   rI   	connectedsock_timeouteblockingnotconn_pre_handshake_datar    notconn_pre_handshake_data_errorr   s                              r1   r)   zSSLSocket.__init__   s     	#$DMM /8 /  ". / / / ?x ? !=>>> # #"&{33DM(1DM% >33H=== A--h@@@ ?//>>> 3))'222"DL$DM&DN*D$DM"DL ??:w//;>>%&IJJJ 	3 3  "2 3 3 3#  "2 3 3 3=' 	H 	HFGGG &.'>$$8!	??,,LOD#';!%"&*#';;==	2 2 2 2 KKMMMMOD00000ODd%HHHH(	J""$$$N IIM  $	7 $	7 $	7w%.(( 

 ''))HU###
1
 .2YYq\\** 1 1 175>5<"@@@-0******	1
 X&&&) 7 Q3;AGV3L3L0:@07;?08JJLLLL   D667 7 7 7 7/$	7P 	%%%# 	#33KJJ* ("oo//G#~~()sttt%%'''''( (    

	 	st   7I M0AM+3K	M+	
K?"K:5M+:K???M+?MM+
M!M+ M!!M++M0AO0 0 Pc           	      B    t          ||||t          |                     S r'   )r$   _wref)r*   r+   r,   r-   r.   s        r1   _gevent_sock_classzSSLSocket._gevent_sock_classd  s     ufeDkkJJJr2   c                 \    d| j         d| j        | j                                        ndS )Nz server=z	, cipher= )rE   r   cipherr*   s    r1   _extra_reprzSSLSocket._extra_reprg  s:     %)\%=DL!!!2E
 	
r2   c                     | j         S r'   )rI   r   s    r1   contextzSSLSocket.contextn  s
    }r2   c                 ,    || _         || j        _        d S r'   )rI   r   r   )r*   ctxs     r1   r   zSSLSocket.contextr  s    "r2   c                 ,    | j         | j         j        S dS )z!The SSLSession for client socket.N)r   rL   r   s    r1   rL   zSSLSocket.sessionw  s     <#<'' $#r2   c                 >    || _         | j        || j        _        d S d S r'   )rJ   r   rL   )r*   rL   s     r1   rL   zSSLSocket.session}  s)    <##*DL    $#r2   c                 ,    | j         | j         j        S dS )z.Was the client session reused during handshakeN)r   session_reusedr   s    r1   r   zSSLSocket.session_reused  s     <#<.. $#r2   c                 :    t          d| j        j        z            )NzCan't dup() %s instances)r}   r0   r3   r   s    r1   dupzSSLSocket.dup  s$    !"<"&."9#: ; ; 	;r2   c                     d S r'   r   )r*   msgs     r1   _checkClosedzSSLSocket._checkClosed  s    r2   c                 @    | j         s|                                  d S d S r'   )r   r   r   s    r1   _check_connectedzSSLSocket._check_connected  s0     	
 	 	r2     c                 ~   |                                   d}	 | j        st          d          |dk    r|dndS 	 | || j                            ||          z  }|S | j                            |pd          S # t          $ r0 | j        dk    r |                     | j        t                     Y nt          $ r0 | j        dk    r |                     | j
        t                     Y nSt          $ r | j        r|dn|cY S  t          $ r.}|j        d         t          k    r| j        r|dn|cY d}~S  d}~ww xY w')	zRead up to LEN bytes and return them.
        Return zero-length string on EOF.

        .. versionchanged:: 24.2.1
           No longer requires a non-None *buffer* to implement ``len()``.
           This is a backport from 3.11.8.
        r   Tz'Read on closed or unwrapped SSL socket.Nr2      rp   timeout_exc)r   r   rq   readr   r   _wait_read_event_SSLErrorReadTimeoutr   _write_eventr   rG   r   r@   r   )r*   nbytesbuffer
bytes_readexs        r1   r   zSSLSocket.read  s    	 
	< L !JKKK{{$nss!3%$,"3"3FF"C"CCJ%%|((4888# O O O<3&&

4+9M
NNNNN$ P P P<3&&

4,:N
OOOOO%   , A"(.33j@@@    71:..43L."(.33j@@@@@@5	s;   !A9 A9 97D:26D:*D:
D:"D5.D:4D55D:c                    |                                   	 | j        st          d          	 | j                            |          S # t          $ r}|j        d         t          k    r.| j        dk    r |                     | j	        t                     nE|j        d         t          k    r.| j        dk    r |                     | j        t                     n Y d}~nd}~ww xY w)zhWrite DATA to the underlying SSL channel.  Returns
        number of bytes of DATA actually transmitted.Tz(Write on closed or unwrapped SSL socket.r   rp   r   N)r   r   rq   writer   r@   r   r   r   r   _SSLErrorWriteTimeoutr   r   )r*   datar   s      r1   r   zSSLSocket.write  s     		< M !KLLL|))$/// 
 
 
71:!444|s**JJt/=RJSSSSWQZ#777|s**JJt0>SJTTTT
	s   A 
C$B	CC$c                     |                                   |                                  	 | j        j        }n# t          $ r | j        j        }Y nw xY w ||          S )zReturns 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.)r   r   r   peer_certificateAttributeErrorgetpeercert)r*   binary_formcs      r1   r   zSSLSocket.getpeercert  sr     		)-AA 	) 	) 	)(AAA	) q~~s   7 AAc                     |                                   | j        rt          j        sd S | j                                        S r'   )r   r   _sslHAS_NPNselected_npn_protocolr   s    r1   r   zSSLSocket.selected_npn_protocol  s@    | 	4< 	4|11333r2   HAS_ALPNc                     |                                   | j        rt          j        sd S | j                                        S r'   )r   r   r   r   selected_alpn_protocolr   s    r1   r   z SSLSocket.selected_alpn_protocol  s@    < t} t<66888r2   c                 4    | j                                         S )zReturn a list of ciphers shared by the client during the handshake or
            None if this is not a valid server connection.
            )r   shared_ciphersr   s    r1   r   zSSLSocket.shared_ciphers  s     <..000r2   c                 F    | j         sdS | j                                         S )z^Return a string identifying the protocol version used by the
            current SSL channel. N)r   versionr   s    r1   r   zSSLSocket.version  s'     < t<'')))r2   c                 n    |                                   | j        sd S | j                                        S r'   )r   r   r   r   s    r1   r   zSSLSocket.cipher  s7    | 	4|""$$$r2   c                 n    |                                   | j        sd S | j                                        S r'   )r   r   compressionr   s    r1   r   zSSLSocket.compression   s7    | 	4|'')))r2   c                    |                                   |t          u r| j        }| j        r|dk    rt	          d| j        z            	 	 | j                            |          S # t          $ r+ | j        dk    rY dS |                     | j	                   Y n7t          $ r+ | j        dk    rY dS |                     | j                   Y nw xY wt          j        | |||          S )Nr   z3non-zero flags not allowed in calls to send() on %sTrp   )r   r   r   r   rq   r0   r   r   r   r   r   r   r   send)r*   r   flagsr   s       r1   r   zSSLSocket.send&  s    o%%lG< 	;zz IN#$ $ $
2	2<--d333' 1 1 1|s** qqJJt/00000( 2 2 2|s** qqJJt0111112
2 ;tT5':::s$   A% %C=CC0CCc                     |                                   | j        rt          d| j        z            |t	          j        | ||          S t	          j        | |||          S )Nz%sendto not allowed on instances of %s)r   r   rq   r0   r   sendto)r*   r   flags_or_addraddrs       r1   r   zSSLSocket.sendto=  sl    < 	-D!^, - - -<=t];;;}T4===r2   c                 0    t          d| j        z            )Nz&sendmsg not allowed on instances of %sr}   r0   r*   r@   kwargss      r1   sendmsgzSSLSocket.sendmsgF  s#     ""J"&.#1 2 2 	2r2   c                     |                                   | j        r|dk    rt          d| j        z            	 t	          j        | ||          S # t          $ r | j        dk    rt          d           w xY w)Nr   z6non-zero flags not allowed in calls to sendall() on %srp   z&The operation did not complete (write))	r   r   rq   r0   r   sendall_socket_timeoutr   r   )r*   r   r   s      r1   r   zSSLSocket.sendallL  s    < 	$zz LN#$ $ $	>$e444 	 	 	|s""'(PQQQ		s   A &A6r   c                     |                                   | j        r:|dk    rt          d| j        z            |dk    rdS |                     |          S t          j        | ||          S )Nr   z3non-zero flags not allowed in calls to recv() on %sr2   )r   r   rq   r0   r   r   r   r*   buflenr   s      r1   r   zSSLSocket.recv\  s~    < 		%zz IN#$ $ $ {{ s99V$$${4///r2   c                 8   |                                   |4|.t          |          5 }|j        }ddd           n# 1 swxY w Y   |sd}| j        r3|dk    rt	          d| j        z            |                     ||          S t          j        | |||          S )z
        .. versionchanged:: 24.2.1
           No longer requires a non-None *buffer* to implement ``len()``.
           This is a backport from 3.11.8.
        Nr   r   z8non-zero flags not allowed in calls to recv_into() on %s)	r   
memoryviewr   r   rq   r0   r   r   	recv_into)r*   r   r   r   views        r1   r   zSSLSocket.recv_intoj  s     	>!'' )4![F) ) ) ) ) ) ) ) ) ) ) ) ) ) ) < 	-zz ![^b^l!lmmm99VV,,,ffe<<<s   <A A c                     |                                   | j        rt          d| j        z            t	          j        | ||          S )Nz'recvfrom not allowed on instances of %s)r   r   rq   r0   r   recvfromr   s      r1   r   zSSLSocket.recvfrom~  sQ    < 	-F!^, - - -tVU333r2   c                     |                                   | j        rt          d| j        z            t	          j        | |||          S )Nz,recvfrom_into not allowed on instances of %s)r   r   rq   r0   r   recvfrom_into)r*   r   r   r   s       r1   r   zSSLSocket.recvfrom_into  sT    < 	-K!^, - - -#D&&%@@@r2   c                 0    t          d| j        z            )Nz&recvmsg not allowed on instances of %sr   r   s      r1   recvmsgzSSLSocket.recvmsg  s!    !"J"&.#1 2 2 	2r2   c                 0    t          d| j        z            )Nz+recvmsg_into not allowed on instances of %sr   r   s      r1   recvmsg_intozSSLSocket.recvmsg_into  s#    ! #')-#8 9 9 	9r2   c                 n    |                                   | j        r| j                                        S dS Nr   )r   r   pendingr   s    r1   r   zSSLSocket.pending  s7    < 	*<'')))qr2   c                 f    |                                   d | _        t          j        | |           d S r'   )r   r   r   shutdown)r*   hows     r1   r   zSSLSocket.shutdown  s3    c"""""r2   c                 *   | j         st          dt          |           z             	 | j         j        }n# t          $ r | j         j        }Y nw xY w| j        }	 	  |            }n# t          $ r) | j        dk    r | 	                    | j
                   Y nit          $ r) | j        dk    r | 	                    | j                   Y n8t          $ r Y n.t          $ r Y n#t          $ r}|j        dk    rY d }~n
 d }~ww xY wd | _         || j        u sJ | S )NNo SSL wrapper around Trp   r   )r   rq   strr   r   unwrapr   r   r   r   r   r   r   r   r   r   r   )r*   r   sr   s       r1   r   zSSLSocket.unwrap  s   | 	C5D		ABBB	+ |,HH 	+ 	+ 	+ |*HHH	+
 J	HJJ# - - - <3&&

4+,,,,,$ . . .<3&&

4,-----   %   
    7a<< EEEE/	<  DJ sE   5 AA
A% %0C=/C=	C=	C=	C='C87C88C=c                 <    d | _         t          j        |            d S r'   )r   r   _real_closer   s    r1   r  zSSLSocket._real_close  s     4     r2   c                 P   |                                   	 	 | j                                         dS # t          $ r0 | j        dk    r |                     | j        t                     Y n<t          $ r0 | j        dk    r |                     | j	        t                     Y nw xY w)zPerform a TLS/SSL handshake.Trp   r   N)
r   r   r   r   r   r   r   _SSLErrorHandshakeTimeoutr   r   r   s    r1   r   zSSLSocket.do_handshake  s    	U
U))+++# T T T<3&&

4+9R
SSSSS$ U U U<3&&

4,:S
TTTTTU	Us   2 7B$+6B$#B$c                 ^    | j                             | j        || j        | j        |          S )N)ownerrL   )r   _wrap_socketr   rH   )r*   rE   rL   s      r1   __create_sslobjzSSLSocket.__create_sslobj  s4    |((JT%9*g ) 
 
 	
r2   c                 r   | j         rt          d          | j        rt          d          |                     d| j                  | _        	 |rt          j        | |          }nd }t          j        | |           |s"| j	        r| 
                                 d| _        |S # t          $ r	 d | _         w xY w)Nz!can't connect in server-side modez/attempt to connect already-connected SSLSocket!FT)rE   rq   r   r   rJ   r   r   
connect_exconnectrF   r   socket_error)r*   r   r	  rcs       r1   _real_connectzSSLSocket._real_connect  s     	B@AAA ? 	PNOOO++E4=AA	 +&tT22tT*** '/ (%%'''"&I 	 	 	DL	s   AB# #B6c                 2    |                      |d           dS )QConnects to remote ADDR, and then wraps the connection in
        an SSL channel.FNr  r*   r   s     r1   r
  zSSLSocket.connect  s      	4'''''r2   c                 .    |                      |d          S )r  Tr  r  s     r1   r	  zSSLSocket.connect_ex  s     !!$---r2   c                     t                                                      \  }}	 | j                            || j        | j        d          }||fS #  |                                  xY w)z
        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.
        T)rF   rG   rE   )r(   acceptrI   r   rF   rG   r   )r*   newsockr   r0   s      r1   r  zSSLSocket.accept  st     ((
	m//(,(D%)%> 	 0  G D= 	MMOOOs   +A A)
tls-uniquec                 $   t          | j        d          r| j                            |          S |t          vrt	          d          |dk    r"t          d                    |                    | j        dS | j                                        S )zGet channel binding data for current connection.  Raise ValueError
        if the requested `cb_type` is not supported.  Return bytes of the data
        or None if the data is not available (e.g. before the handshake).
        get_channel_bindingz Unsupported channel binding typer  z({0} channel binding type not implementedN)rk   r   r  r   rq   r}   formattls_unique_cb)r*   cb_types     r1   r  zSSLSocket.get_channel_binding-  s    
 4<!677 	=<33G<<<///?@@@l""%&P&W&WX_&`&`aaa<4|))+++r2   c                     | j         r| j                                         S t          dt          |           z             )Nr   )r   verify_client_post_handshakerq   r   r   s    r1   r  z&SSLSocket.verify_client_post_handshake=  s:    < 	?<<<>>>1CII=>>>r2   get_verified_chainc                 T    | j                                         }|g S d |D             S )Nc                 L    g | ]!}|                     t          j                  "S r   public_bytesr   ENCODING_DER.0certs     r1   
<listcomp>z0SSLSocket.get_verified_chain.<locals>.<listcomp>K  )    KKKTD%%d&788KKKr2   )r   r  r*   chains     r1   r  zSSLSocket.get_verified_chainE  s3    L3355E}	KKUKKKKr2   c                 T    | j                                         }|g S d |D             S )Nc                 L    g | ]!}|                     t          j                  "S r   r!  r$  s     r1   r'  z2SSLSocket.get_unverified_chain.<locals>.<listcomp>S  r(  r2   )r   get_unverified_chainr)  s     r1   r-  zSSLSocket.get_unverified_chainM  s3    L5577E}	KKUKKKKr2   r'   )r   N)F)r   )r   r   r   )FN)r  ):r3   r4   r5   __doc__r   r   r   r   r)   r   r   rl   r   rM   rL   r   r   r   r   r   r   r   r   rk   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r  r
  r	  r  r  r  rd   r
   r  r-  r7   r8   s   @r1   r
   r
      s         !$"i,t)-k4&*$!%K K K KZK K K
 
 
   X ^# # ^# ( ( X(
 ^+ + ^+
 / / X/
; ; ;     2 2 2 2z  .    4 4 4 wtZ   *	9 	9 	9	1 	1 	1	* 	* 	*% % %* * *  !/ ; ; ; ;.> > > >2 2 2    0 0 0 0= = = =(4 4 4 4A A A A2 2 29 9 9  # # #
: : :x! ! !U U U&
 
 
 
  0( ( (
. . .
    &, , , , ? ? ? ww "677 L	L 	L 	L	L 	L 	L 	L 	L 	L 	LL L L Lr2   r
   zThe read operation timed outzThe write operation timed outz!The handshake operation timed outFTc
                 4    t          | |||||||||	
  
        S )N
rD   rv   rw   rE   rx   ry   rz   rF   rG   r{   )r
   r0  s
             r1   r   r   _  s4     $(!,	!,x-D*>$& & & &r2   c                 "   | \  }}|t           }nt          }t          |           5 }t          ||||          5 }|                    d          }ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   dx}}t          |          S )zRetrieve 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.N)ry   rx   rz   T)r   r   r   r   r   r   )r   ry   rz   _rx   rD   sslsockdercerts           r1   r   r   n  s     DAq!				4	 	  0D;#,xA A A 	0DK))$//G	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Gd(((s4   A3AA3A 	 A3#A 	$A33A7:A7):r.  
__future__r   sslrd   r   r   gevent.socketr   r   r   r   gevent._utilr   r   r  weakrefr   r   __implements__rk   append	__extra__r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   globals__imports____all__remover	   rO   r   r$   objectr:   r
   rK   r   r   r  r   r   r   r2   r1   <module>rB     s    ' & & & & &    |  2 1 1 1 1 1 1 1 4 4 4 4 4 4 % % % % % %               77M"" -(((II 	I                                     ! ! ! ! ! !       " " " " " "                   # # # # # # $ $ $ $ $ $       & % % % % %       $ $ $ $ $ $ ! ! ! ! ! ! lWWYY"hZ/	   ;
&
27NN<   $' ' ' ' '1 ' ' '	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/`B `B `B `B `B `B `B `BFE
L E
L E
L E
L E
L E
L E
L E
LP '
  ''EFF '(GHH +O,OPP  #T!Y+d(,%)& & & & .=t ) ) ) ) ) )r2   