+
    üÐj)2  ã            
       ó^  € R t ^ RIHtHtHt ^ RIHtHt ^ RIH	t	H
t
 ^ RIHtHtHt ^ RIHt ^ RIHtHtHt ^ RIHtHtHt ^ RIHtHtHt ^ R	IHt ^ R
IH t H!t!H"t" ^ RI#H$t$ ^ RI%H&t& ^ RI'H(t( ^ RI)H*t*  ^ RI+H,t, ^ RI-H.t.H/t/H0t0  ! R R4      t2 ! R R4      t3]! ]4       ! R R4      4       t4 ! R R]]34      t5 ! R R4      t6 ! R R]2]]4      t7 ! R R]]34      t8 ! R  R!]2]]3]]64      t9 ! R" R#]2]3]6]!]"]4      t:];! 4       Py                  ]9P{                  4       4       ];! 4       Py                  ]7P{                  4       4       ];! 4       Py                  ]:! 4       P{                  4       4        ! R$ R%]] ]34      t>];! 4       Py                  ]>P{                  4       4       R#   ]1 d    Rt, EL'i ; i)&z0
Tests for implementations of L{ITLSTransport}.
)ÚOptionalÚSequenceÚType)Ú	InterfaceÚimplementer)ÚDeferredÚDeferredList)ÚSSL4ClientEndpointÚSSL4ServerEndpointÚTCP4ClientEndpoint)ÚConnectionClosed)ÚIReactorSSLÚIStreamClientEndpointÚITLSTransport)ÚClientFactoryÚProtocolÚServerFactory)ÚBrokenContextFactoryÚConnectionTestsMixinÚEndpointCreator)ÚReactorBuilder)ÚAbortConnectionMixinÚConnectToTCPListenerMixinÚStreamTransportTestsMixin)ÚnetworkString)ÚFilePath)Úplatform)ÚSkipTest)ÚFILETYPE_PEM)ÚClientContextFactoryÚKeyPairÚPrivateCertificateNc                   óp   a € ] tR t^2t o ].t]P                  ! 4       '       d	   RtR]R]/t	V 3R lt
RtV tR# )ÚTLSMixinzcFor some reason, these reactors don't deal with SSL disconnection correctly on Windows.  See #3371.z*twisted.internet.glib2reactor.Glib2Reactorz(twisted.internet.gtk2reactor.Gtk2Reactorc                óV   <€ V ^8„  d   Qh/ S[ S[S[S[,          ,          ,          ;R&   # )é   ÚrequiredInterfaces)r   r   r   r   )ÚformatÚ__classdict__s   "€Ú@/usr/lib/python3/dist-packages/twisted/internet/test/test_tls.pyÚ__annotate__ÚTLSMixin.__annotate__2   s   ø‡ ‚ Ù ¡©$©y­/Õ!:Õ;ÑKò ó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r&   r   Ú	isWindowsÚmsgÚskippedReactorsÚ__annotate_func__Ú__static_attributes__Ú__classdictcell__©r(   s   @r)   r#   r#   2   s@   ø‡ € Ø?J¸mÐà×Ò×Òð>ð 	ð
 9¸#Ø6¸ð
ˆ÷ ƒ r,   r#   c                   ó¢   a € ] tR t^@t o ^ RIt]! ]! ]P                  4      4      P                  R4      P                  R4      t
AR tR tRtV tR# )ÚContextGeneratingMixinNs   tests
   server.pemc                óÀ   € V P                   P                  4       p\        P                  ! V\        P                  ! V\
        4      \
        4      pVP                  4       # )z=
Return a new SSL context suitable for use in a test server.
)Ú_pemÚ
getContentr!   Úloadr    r   Úoptions)ÚselfÚpemÚcerts   &  r)   ÚgetServerContextÚ'ContextGeneratingMixin.getServerContextH   sF   € ð �i‰i×"Ñ"Ó$ˆÜ!×&Ò&Ø”—’˜c¤<Ó0´,ó
ˆð �|‰|‹~Ðr,   c                ó   € \        4       # ©N)r   ©r@   s   &r)   ÚgetClientContextÚ'ContextGeneratingMixin.getClientContextR   s   € Ü#Ó%Ð%r,   r-   )r.   r/   r0   r1   Útwistedr   r   Ú__file__ÚsiblingÚchildr<   rC   rH   r6   r7   r8   s   @r)   r:   r:   @   sL   ø‡ € Ûñ 	‘˜w×/Ñ/Ó0Ó1×9Ñ9¸'ÓB×HÑHÈÓWð 	ð 	ò÷&ð &r,   r:   c                   ó0   a € ] tR t^Vt o RtR tR tRtV tR# )ÚStartTLSClientEndpointa	  
An endpoint which wraps another one and adds a TLS layer immediately when
connections are set up.

@ivar wrapped: A L{IStreamClientEndpoint} provider which will be used to
    really set up connections.

@ivar contextFactory: A L{ContextFactory} to use to do TLS.
c                ó   € Wn         W n        R # rF   )ÚwrappedÚcontextFactory)r@   rQ   rR   s   &&&r)   Ú__init__ÚStartTLSClientEndpoint.__init__b   s   € ØŒØ,Ör,   c                ól   a a€  ! VV 3R lR\         4      pS P                  P                  V! 4       4      # )zœ
Establish a connection using a protocol build by C{factory} and
immediately start TLS on it.  Return a L{Deferred} which fires with the
protocol instance.
c                   ó0   <a € ] tR t^ot o VV3R ltRtV tR# )Ú6StartTLSClientEndpoint.connect.<locals>.WrapperFactoryc                ób   <a€ SP                  V4      oSP                  3VV3R  llpVSn        S# )c                 ó`   <€ SP                   P                  SP                  4       V ! 4        R # rF   )Ú	transportÚstartTLSrR   )ÚorigÚprotocolr@   s   &€€r)   ÚconnectionMadeÚ\StartTLSClientEndpoint.connect.<locals>.WrapperFactory.buildProtocol.<locals>.connectionMades   s"   ø€ Ø×&Ñ&×/Ñ/°×0CÑ0CÔDÙ–Fr,   )ÚbuildProtocolr^   )ÚwrapperSelfÚaddrr^   r]   Úfactoryr@   s   && @€€r)   r`   ÚDStartTLSClientEndpoint.connect.<locals>.WrapperFactory.buildProtocolp   s5   ù€ Ø"×0Ñ0°Ó6�à(0×(?Ñ(?÷ ð ð +9�Ô'Ø�r,   r-   N)r.   r/   r0   r1   r`   r6   r7   )r(   rc   r@   s   @€€r)   ÚWrapperFactoryrW   o   s   ù‡ € ÷ ô  r,   re   )r   rQ   Úconnect)r@   rc   re   s   ff r)   rf   ÚStartTLSClientEndpoint.connectf   s.   ù€ ÷		 ð 		 œ]ô 		 ð �|‰|×#Ñ#¡NÓ$4Ó5Ð5r,   )rR   rQ   N)	r.   r/   r0   r1   Ú__doc__rS   rf   r6   r7   r8   s   @r)   rO   rO   V   s   ø‡ € ñò-÷6ð 6r,   rO   c                   ó0   a € ] tR t^}t o RtR tR tRtV tR# )ÚStartTLSClientCreatorzo
Create L{ITLSTransport.startTLS} endpoint for the client, and normal SSL
for server just because it's easier.
c                ó8   € \        V^ V P                  4       4      # )z•
Construct an SSL server endpoint.  This should be constructing a TCP
server endpoint which immediately calls C{startTLS} instead, but that
is hard.
©r
   rC   ©r@   Úreactors   &&r)   ÚserverÚStartTLSClientCreator.serverƒ   s   € ô " '¨1¨d×.CÑ.CÓ.EÓFÐFr,   c                óT   € \        \        VRVP                  4      \        4       4      # )zC
Construct a TCP client endpoint wrapped to immediately start TLS.
ú	127.0.0.1)rO   r   Úportr   ©r@   rn   ÚserverAddresss   &&&r)   ÚclientÚStartTLSClientCreator.client‹   s)   € ô &Ü˜w¨°]×5GÑ5GÓHÜ Ó"ó
ð 	
r,   r-   N©	r.   r/   r0   r1   rh   ro   rv   r6   r7   r8   s   @r)   rj   rj   }   s   ø‡ € ñò
G÷
ð 
r,   rj   c                   ó*   a € ] tR t^•t o RtR tRtV tR# )ÚBadContextTestsMixinzu
Mixin for L{ReactorBuilder} subclasses which defines a helper for testing
the handling of broken context factories.
c                ó¶   € V P                  4       pV P                  \        W\        4       4      pV P	                  \        P
                  \        V4      4       R# )a�  
Assert that the exception raised by a broken context factory's
C{getContext} method is raised by some reactor method.  If it is not, an
exception will be raised to fail the test.

@param useIt: A two-argument callable which will be called with a
    reactor and a broken context factory and which is expected to raise
    the same exception as the broken context factory's C{getContext}
    method.
N)ÚbuildReactorÚassertRaisesÚ
ValueErrorr   ÚassertEqualÚmessageÚstr)r@   ÚuseItrn   Úexcs   &&  r)   Ú_testBadContextÚ$BadContextTestsMixin._testBadContext›   sE   € ð ×#Ñ#Ó%ˆØ×Ñ¤
¨EÔ<PÓ<RÓSˆØ×ÑÔ-×5Ñ5´s¸3³xÖ@r,   r-   N)r.   r/   r0   r1   rh   r„   r6   r7   r8   s   @r)   rz   rz   •   s   ø‡ € ñ÷
Að Ar,   rz   c                   ó(   € ] tR t^«tRt]! 4       tRtR# )ÚStartTLSClientTestsMixinzŽ
Tests for TLS connections established using L{ITLSTransport.startTLS} (as
opposed to L{IReactorSSL.connectSSL} or L{IReactorSSL.listenSSL}).
r-   N)r.   r/   r0   r1   rh   rj   Ú	endpointsr6   r-   r,   r)   r‡   r‡   «   s   † ññ
 &Ó'„Ir,   r‡   c                   ó0   a € ] tR t^´t o RtR tR tRtV tR# )Ú
SSLCreatorz
Create SSL endpoints.
c                ó8   € \        V^ V P                  4       4      # )zA
Create an SSL server endpoint on a TCP/IP-stack allocated port.
rl   rm   s   &&r)   ro   ÚSSLCreator.server¹   s   € ô " '¨1¨d×.CÑ.CÓ.EÓFÐFr,   c                óB   € \        VRVP                  \        4       4      # )zˆ
Create an SSL client endpoint which will connect localhost on
the port given by C{serverAddress}.

@type serverAddress: L{IPv4Address}
rr   )r	   rs   r   rt   s   &&&r)   rv   ÚSSLCreator.client¿   s$   € ô "Ø�[ -×"4Ñ"4Ô6JÓ6Ló
ð 	
r,   r-   Nrx   r8   s   @r)   rŠ   rŠ   ´   s   ø‡ € ñòG÷	
ð 	
r,   rŠ   c                   ó>   a € ] tR t^Ët o Rt]! 4       tR tR tRt	V t
R# )ÚSSLClientTestsMixinz4
Mixin defining tests relating to L{ITLSTransport}.
c                ó.   € R pV P                  V4       R# )z¦
If the context factory passed to L{IReactorSSL.connectSSL} raises an
exception from its C{getContext} method, that exception is raised by
L{IReactorSSL.connectSSL}.
c                 ó:   € V P                  R R\        4       V4      # )rr   iÒ  )Ú
connectSSLr   ©rn   rR   s   &&r)   r‚   Ú2SSLClientTestsMixin.test_badContext.<locals>.useItß   s    € Ø×%Ñ%Ø˜T¤=£?°Nóð r,   N©r„   ©r@   r‚   s   & r)   Útest_badContextÚ#SSLClientTestsMixin.test_badContextØ   s   € ò	ð
 	×Ñ˜UÖ#r,   c                ó°  aa	€  ! R R\         4      pV P                  4       o	\        4       p\        4       Vn        Wn        V P                  4       Vn        \        4       p\        4       Vn        Wn        V P                  4       Vn        VP                  P                  VP                  n
        . o\        VP                  VP                  .RR7      pV3R lpVP                  V4       S	P                  ^ VRR7      pV P                  VP                  4       S	P!                  VP#                  4       P$                  VP#                  4       P&                  V4      pV P                  VP(                  4       VP                  V	3R l4       V P+                  S	4       S^ ,          P-                  \.        4       S^,          P-                  \.        4       R	# )
a  
L{ITCPTransport.loseConnection} ends a connection which was set up with
L{ITLSTransport.startTLS} and which has recently been written to.  This
is intended to verify that a socket send error masked by the TLS
implementation doesn't prevent the connection from being reported as
closed.
c                   ó2   a € ] tR t^ït o R tR tR tRtV tR# )ÚQSSLClientTestsMixin.test_disconnectAfterWriteAfterStartTLS.<locals>.ShortProtocolc                ól  € \         P                  ! V P                  4      '       gD   V P                  P                  pR V P                  n        VP                  \        R4      4       R # V P                  P                  V P                  P                  4       V P                  P                  R4       R # )NzNo ITLSTransport supportó   x)
r   Ú
providedByrZ   rc   ÚfinishedÚerrbackr   r[   ÚcontextÚwrite)r@   r    s   & r)   r^   Ú`SSLClientTestsMixin.test_disconnectAfterWriteAfterStartTLS.<locals>.ShortProtocol.connectionMadeð   s{   € Ü$×/Ò/°·±×?Ò?à#Ÿ|™|×4Ñ4�HØ,0�D—L‘LÔ)Ø×$Ñ$¤XÐ.HÓ%IÔJÙð —‘×'Ñ'¨¯©×(<Ñ(<Ô=ð —‘×$Ñ$ TÖ*r,   c                óp   € V P                   P                  R 4       V P                   P                  4        R# )ó   yN)rZ   r£   ÚloseConnection)r@   Údatas   &&r)   ÚdataReceivedÚ^SSLClientTestsMixin.test_disconnectAfterWriteAfterStartTLS.<locals>.ShortProtocol.dataReceivedþ   s(   € ð
 —‘×$Ñ$ TÔ*ð —‘×-Ñ-Ö/r,   c                ó‚   € V P                   P                  pVe%   R V P                   n        VP                  V4       R # R # rF   )rc   r    Úcallback)r@   Úreasonr    s   && r)   ÚconnectionLostÚ`SSLClientTestsMixin.test_disconnectAfterWriteAfterStartTLS.<locals>.ShortProtocol.connectionLost  s8   € ð  Ÿ<™<×0Ñ0�ØÒ'Ø,0�D—L‘LÔ)Ø×%Ñ% fÖ-ñ (r,   r-   N)	r.   r/   r0   r1   r^   r©   r®   r6   r7   r8   s   @r)   ÚShortProtocolrœ   ï   s   ø‡ € ò+ò0÷.ð .r,   r°   T)ÚconsumeErrorsc                 óf   <€ SP                  V ^ ,          ^,          V ^,          ^,          .4       R# )é    N)Úextend)ÚresultsÚlostConnectionResultss   &€r)   Ú
cbFinishedÚNSSLClientTestsMixin.test_disconnectAfterWriteAfterStartTLS.<locals>.cbFinished"  s&   ø€ Ø!×(Ñ(¨'°!­*°Q­-¸À½ÀA½Ð)GÖHr,   rr   )Ú	interfacec                 ó$   <€ SP                  4       # rF   )Ústop)Úignrn   s   &€r)   Ú<lambda>ÚLSSLClientTestsMixin.test_disconnectAfterWriteAfterStartTLS.<locals>.<lambda>/  s   ø€ ¨¯©¬r,   N)r   r|   r   r   r    r]   rC   r¢   r   rH   Úmethodr   ÚaddCallbackÚ	listenTCPÚ
addCleanupÚstopListeningÚ
connectTCPÚgetHostÚhostrs   Ú
disconnectÚ
runReactorÚtrapr   )
r@   r°   ÚserverFactoryÚclientFactoryr    r·   rs   Ú	connectorr¶   rn   s
   &       @@r)   Ú&test_disconnectAfterWriteAfterStartTLSÚ:SSLClientTestsMixin.test_disconnectAfterWriteAfterStartTLSæ   su  ù€ ô	.œHô 	.ðB ×#Ñ#Ó%ˆä%›ˆÜ!)£ˆÔØ!.ÔØ $× 5Ñ 5Ó 7ˆÔä%›ˆÜ!)£ˆÔØ!.ÔØ $× 5Ñ 5Ó 7ˆÔØ'4×'<Ñ'<×'CÑ'Cˆ×ÑÔ$à "ÐÜØ×#Ñ# ]×%;Ñ%;Ð<ÈDô
ˆõ	Ið 	×Ñ˜ZÔ(à× Ñ   M¸[Ð ÓIˆØ�‰˜×*Ñ*Ô+à×&Ñ&Ø�L‰L‹N×Ñ §¡£×!4Ñ!4°mó
ˆ	ð 	�‰˜	×,Ñ,Ô-à×ÑÔ7Ô8Ø�‰˜Ô Ø˜aÕ ×%Ñ%Ô&6Ô7Ø˜aÕ ×%Ñ%Ô&6Ö7r,   r-   N)r.   r/   r0   r1   rh   rŠ   rˆ   r˜   rÍ   r6   r7   r8   s   @r)   r�   r�   Ë   s$   ø‡ € ññ “€Iò$÷L8ð L8r,   r�   c                   óB   a € ] tR tRt o RtR tR tR tR tR t	Rt
V tR	# )
ÚTLSPortTestsBuilderi5  z$
Tests for L{IReactorSSL.listenSSL}
c                óB   € VP                  ^ W P                  4       4      # )z 
Get a TLS port from a reactor.
)Ú	listenSSLrC   )r@   rn   rc   s   &&&r)   ÚgetListeningPortÚ$TLSPortTestsBuilder.getListeningPortA  s    € ð × Ñ   G×-BÑ-BÓ-DÓEÐEr,   c                óF   € RW!P                  4       P                  3,          # )zI
Get the message expected to be logged when a TLS port starts listening.
z%s (TLS) starting on %d©rÅ   rs   )r@   rs   rc   s   &&&r)   Ú#getExpectedStartListeningLogMessageÚ7TLSPortTestsBuilder.getExpectedStartListeningLogMessageG  s   € ð )¨G·\±\³^×5HÑ5HÐ+IÕIÐIr,   c                ó>   € RVP                  4       P                   R2# )z:
Get the expected connection lost message for a TLS port.
z
(TLS Port z Closed)rÖ   )r@   rs   s   &&r)   ÚgetExpectedConnectionLostLogMsgÚ3TLSPortTestsBuilder.getExpectedConnectionLostLogMsgM  s    € ð ˜DŸL™L›N×/Ñ/Ð0°Ð9Ð9r,   c                ó.   € R pV P                  V4       R# )z¤
If the context factory passed to L{IReactorSSL.listenSSL} raises an
exception from its C{getContext} method, that exception is raised by
L{IReactorSSL.listenSSL}.
c                 ó8   € V P                  ^ \        4       V4      # )r³   )rÒ   r   r”   s   &&r)   r‚   Ú2TLSPortTestsBuilder.test_badContext.<locals>.useItZ  s   € Ø×$Ñ$ Q¬«¸ÓHÐHr,   Nr–   r—   s   & r)   r˜   Ú#TLSPortTestsBuilder.test_badContextS  s   € ò	Ið 	×Ñ˜UÖ#r,   c                ón   € VP                  V P                  VP                  VV P                  4       4      # )a¯  
Connect to the given listening TLS port, assuming the
underlying transport is TCP.

@param reactor: The reactor under test.
@type reactor: L{IReactorSSL}

@param address: The listening's address.  Only the C{port}
    component is used; see
    L{ConnectToTCPListenerMixin.LISTENER_HOST}.
@type address: L{IPv4Address} or L{IPv6Address}

@param factory: The client factory.
@type factory: L{ClientFactory}

@return: The connector
)r“   ÚLISTENER_HOSTrs   rH   )r@   rn   Úaddressrc   s   &&&&r)   ÚconnectToListenerÚ%TLSPortTestsBuilder.connectToListener_  s6   € ð$ ×!Ñ!Ø×ÑØ�L‰LØØ×!Ñ!Ó#ó	
ð 	
r,   r-   N)r.   r/   r0   r1   rh   rÓ   r×   rÚ   r˜   rã   r6   r7   r8   s   @r)   rÐ   rÐ   5  s*   ø‡ € ñòFòJò:ò
$÷
ð 
r,   rÐ   c                   ó>   a € ] tR tRt o Rt]3t]! 4       tR t	Rt
V tR# )ÚAbortSSLConnectionTestsi~  z%
C{abortConnection} tests using SSL.
c                ó,   € \         f   \        R4      hR # )NzOpenSSL not available.)r   r   rG   s   &r)   ÚsetUpÚAbortSSLConnectionTests.setUpˆ  s   € ÜÒÜÐ3Ó4Ð4ñ  r,   r-   N)r.   r/   r0   r1   rh   r   r&   rŠ   rˆ   rè   r6   r7   r8   s   @r)   ræ   ræ   ~  s%   ø‡ € ñð &˜ÐÙ“€I÷5ð 5r,   ræ   )?rh   Útypingr   r   r   Úzope.interfacer   r   Útwisted.internet.deferr   r   Útwisted.internet.endpointsr	   r
   r   Útwisted.internet.errorr   Útwisted.internet.interfacesr   r   r   Útwisted.internet.protocolr   r   r   Ú&twisted.internet.test.connectionmixinsr   r   r   Ú#twisted.internet.test.reactormixinsr   Útwisted.internet.test.test_tcpr   r   r   Útwisted.python.compatr   Útwisted.python.filepathr   Útwisted.python.runtimer   Útwisted.trial.unittestr   ÚOpenSSL.cryptor   Útwisted.internet.sslr   r    r!   ÚImportErrorr#   r:   rO   rj   rz   r‡   rŠ   r�   rÐ   ÚglobalsÚupdateÚmakeTestCaseClassesræ   r-   r,   r)   Ú<module>rþ      s¶  ðñ÷
 ,Ñ +ç 1ç 9÷ñ õ
 4÷ñ ÷
 MÑ L÷ñ õ
 ?÷ñ õ
 0Ý ,Ý +Ý +ðWÝ+÷ WÑV÷
ñ 
÷&ñ &ñ, Ð"Ó#÷#6ð #6ó $ð#6ôL
˜OÐ-Cô 
÷0Añ Aô,(˜x¨Ð9Mô (ô
�Ð"8ô 
ô.g8ØØØØØôg8ôTA
ØØØØØØôA
ñH ƒ	× Ñ Ð$×8Ñ8Ó:Ô ;Ù ƒ	× Ñ Ð)×=Ñ=Ó?Ô @Ù ƒ	× Ñ Ñ$Ó&×:Ñ:Ó<Ô =ô5ØÐ(Ð*@ô5ñ ƒ	× Ñ Ð(×<Ñ<Ó>Ö ?øðC ô ØƒLðús   Á4F Æ	F,Æ+F,