+
    Bi             
          ^ RI t ^ RIt^ RI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 ^ RI	Ht ^ R	I	Ht ^ R
I	Ht ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI t ^ RI!t!^ RI"t"^ RI#t#^ RI$H%t%  ^ RI&t&]
PP                  ! R4      t)^ RI*t*^ RI)H+t+H,t,H-t-H.t.H/t/ ]P`                  ;'       d    ] PB                  R8H  t1]2! ])Pf                  4      t4]Pj                  t5])Pl                  Rv8  t7]"Pp                  ! R4      t9/ t:Rw F(  w  t;t< ]=! ])];4      t;]=! ])PX                  ]<4      t<]<]:];&   K*  	  R t?]?! R4      t@]P                  ! ]@4      tB]?! R4      tC]?! R4      tD]P                  ! ]C4      tE]P                  ! ]D4      tF]?! R4      tG]?! R4      tHRtI]?! R4      tJ]P                  ! ]J4      tK]?! RR4      tL]?! RR4      tM]N! ]?! R4      4      ;_uu_ 4       tO]! ]OP                  4       4      tQRRR4       ]?! R4      tR]?! R4      tS]?! R4      tTRtU]N! ]?! R4      4      ;_uu_ 4       tO]! ]OP                  4       4      tVRRR4       ]?! R 4      tWR!tX]?! R"4      tYR#tZ]?! R$4      t[R%t\]?! R&4      t]]?! RR'4      t^]?! R(4      t_]?! R)4      t`]?! R*4      taRtbR+tc]?! R,4      td]?! R-4      te]?! R.4      tf]?! R/4      tg]?! R04      th]?! R14      ti]?! R24      tj]?! R34      tk]P                  ! ]k4      tl]=! ])R4^ 4      tm]=! ])R5^ 4      tn]=! ])R6^ 4      to]=! ])R7^ 4      tp]=! ])R8^ 4      tqR9 tr]r! 4       '       d   R: tsMR; tsR< tt]#P                  R= 4       tvR> twR? txR@ ty]P                  ! ]{RA7      t|RB])P                  RCRRDRRERRFR/RG lt~RHsRs]S3RIRJ/RK llt ! RL RM]EP                  4      t ! RN RO]EP                  4      t ! RP RQ]EP                  4      t ! RR RS]EP                  4      t ! RT RU]EP                  4      t ! RV RW]EP                  4      t]EP                  ! RX4       ! RY RZ]EP                  4      4       tRxR[ ltR\ t^ R]IHt  ! R^ R_]P                  4      t ! R` Ra]P                  4      tRyRb ltRzRc ltRd t ! Re Rf]EP                  4      t]EP*                  ! ]v! Rg4      ;'       d    ])EP,                  Rh4       ! Ri Rj]EP                  4      4       t]! ])EP2                  Rk4      t]EP*                  ! ]Rl4      t ! Rm Rn]EP                  4      tRo t ! Rp Rq]EP                  4      t ! Rr Rs]EP                  4      tRt t]Ru8X  d   ]EPD                  ! 4        R# R#   ]' d    Rt& ELi ; i  ]> d     EKx  i ; i  + '       g   i     EL; i  + '       g   i     ELb; i){    N)literal_eval)Thread)support)import_helper)	os_helper)socket_helper)threading_helper)warnings_helper)asyncore)nullcontextssl)Purpose
TLSVersion_TLSContentType_TLSMessageType_TLSAlertTypewin32PY_SSL_DEFAULT_CIPHERSc                      \         P                  P                  ! \         P                  P                  \        4      R .V O5!  # )certdata)ospathjoindirname__file__names   *$/usr/lib/python3.14/test/test_ssl.py	data_filer   B   s)    77<<1:EEE    zkeycert.pemzssl_cert.pemzssl_key.pemzkeycert.passwd.pemzssl_key.passwd.pemsomepasscapathz
4e1295a3.0z
5ed36f99.0zkeycert.pem.referencezrevocation.crlzkeycert3.pemz	cert3.pem	localhostzkeycert3.pem.referencezkeycert4.pemfakehostnamezkeycertecc.pemzlocalhost-ecczleaf-missing-aki.keycert.pemzexample.comzleaf-missing-aki.ca.pemz
ceff1710.0zallsans.pemzidnsans.pemz	nosan.pemzself-signed.pythontest.netnullcert.pembadcert.pemzXXXnonexisting.pem
badkey.pemz	nokia.pemznullbytecert.pemztalos-2019-0758.pemzffdh3072.pemOP_NO_COMPRESSIONOP_SINGLE_DH_USEOP_SINGLE_ECDH_USEOP_CIPHER_SERVER_PREFERENCEOP_ENABLE_MIDDLEBOX_COMPATc                       \        R RR7      ;_uu_ 4       p RV P                  4       9   uuRRR4       #   + '       g   i     R# ; i  \         d     R# i ; i)z/etc/os-releasezutf-8)encodingubuntuNF)openreadFileNotFoundError)fs    r   	is_ubuntur4      sG     #g66!qvvx' 7666 s+   A	 5
A	 A	 A	 A	 	AAc                     V  Ff  p\        VR4      '       g   K  VP                  \        P                  P                  8:  g   KB  VP
                  ^8  g   KU  VP                  R4       Kh  	  R# )z?Lower security level to '1' and allow all ciphers for TLS 1.0/1minimum_versionz@SECLEVEL=1:ALLN)hasattrr6   r   r   TLSv1_1security_levelset_ciphers)ctxsctxs   * r   seclevel_workaroundr=      sM    C.//##s~~'='==""Q& 12 r    c                      R # N )r;   s   *r   r=   r=      s    r    c                @   \        V \        4      '       d1   V P                  R4      '       g   Q h\        \        V R4      p V f   R# V \        P
                  \        P                  \        P                  09   d   R# V P                  p\        V\        R4      R 4      # )ztCheck if a TLS protocol is available and enabled

:param protocol: enum ssl._SSLMethod member or name
:return: bool
	PROTOCOL_NFT)
isinstancestr
startswithgetattrr   PROTOCOL_TLSPROTOCOL_TLS_SERVERPROTOCOL_TLS_CLIENTr   has_tls_versionlen)protocolr   s   & r   has_tls_protocolrM      s     (C  "";////3$/#11 
 ==D4K 0 1233r    c                   \        V \        4      '       d"   \        P                  P                  V ,          p \        \        RV P                   24      '       g   R# \        '       d"   V \        P                  P                  8  d   R# \        P                  \        P                  4      p\        VR4      '       d<   VP                  \        P                  P                  8w  d   WP                  8  d   R# \        VR4      '       d<   VP                  \        P                  P                  8w  d   WP                  8  d   R# R# )zoCheck if a TLS/SSL version is enabled

:param version: TLS version name or ssl.TLSVersion member
:return: bool
HAS_Fr6   maximum_versionT)rC   rD   r   r   __members__rF   r   IS_OPENSSL_3_0_0TLSv1_2
SSLContextrI   r7   r6   MINIMUM_SUPPORTEDrP   MAXIMUM_SUPPORTED)versionr<   s   & r   rJ   rJ      s     '3..,,W5 3$w||n-..Gcnn&<&<< ..00
1CC*++3>>#C#CC)))&''s~~???%%%r    c                   a  V 3R lpV# )zDecorator to skip tests when a required TLS version is not available

:param version: TLS version name or ssl.TLSVersion member
:return:
c                 J   <a  \         P                  ! S 4      V V3R  l4       pV# )c                  h   < \        S4      '       g   \        P                  ! S R 24      hS! V / VB # )z is not available.)rJ   unittestSkipTest)argskwfuncrW   s   *,r   wrapper8requires_tls_version.<locals>.decorator.<locals>.wrapper   s7    "7++''7)3E(FGGT(R((r    )	functoolswraps)r_   r`   rW   s   f r   	decorator'requires_tls_version.<locals>.decorator   s%    			) 
	)
 r    r@   )rW   rd   s   f r   requires_tls_versionrf      s     r    c                     R P                  \        P                  ! \        P                  ! 4       4      4      p\
        P                  '       d(   \        P                  P                  W,           4       R# R# ) N)	r   	tracebackformat_exceptionsys	exceptionr   verbosestdoutwrite)prefix
exc_formats   & r   handle_errorrr      sD    )44S]]_EFJ

,- r    c                      \         P                  '       d6   \         P                  ! 4       P                  ^ 8  d   \         P                  ) # \         P
                  ) # )r   )timedaylight	localtimetm_isdstaltzonetimezoner@   r    r   
utc_offsetrz      s7    }}})22Q6}MM>r    )category	cert_reqsca_certscipherscertfilekeyfilec                   VP                  R 4      '       g.   \        VR&   \        P                  \        P                  4      pM#\        P                  \        P
                  4      pVe#   V\        P                  8X  d   RVn        Wn        Ve   VP                  V4       Vf   Ve   VP                  WE4       Ve   VP                  V4       VP                  ! V 3/ VB # )server_sideserver_hostnameF)getSIGNED_CERTFILE_HOSTNAMEr   rT   rI   rH   	CERT_NONEcheck_hostnameverify_modeload_verify_locationsload_cert_chainr:   wrap_socket)sockr|   r}   r~   r   r   kwargscontexts   &$$$$$, r   test_wrap_socketr     s     ::m$$$< !..!8!89..!8!89%%*G"'%%h/w22G$t.v..r    Fserver_chainTc                  \         '       d   \        e   \        # V \        8X  d   \        pM/V \        8X  d   \
        pMV \        8X  d   \        pM\        V 4      h\        P                  \        P                  4      pVP                  \        4       \        P                  \        P                  4      pVP                  V 4       V'       d   VP                  \        4       \         '       d   \        e   W4V3sW4V3# )zMCreate context

client_context, server_context, hostname = testing_context()
)USE_SAME_TEST_CONTEXT_TEST_CONTEXTSIGNED_CERTFILEr   SIGNED_CERTFILE2SIGNED_CERTFILE2_HOSTNAME	NOSANFILENOSAN_HOSTNAME
ValueErrorr   rT   rI   r   
SIGNING_CArH   r   )server_certr   hostnameclient_contextserver_contexts   &$   r   testing_contextr     s     $  o%+	(	(,			!!%%^^C$;$;<N((4^^C$;$;<N"";/,,Z8$*HDM833r    c                   P  a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tR tR t]P"                  R 4       tR tR tR tR tR tR tR tR tR t]P:                  ! R]P>                  9   R4      R 4       t R t!R t"]P:                  ! ]#PH                  R8H  R4      R 4       t%]P:                  ! ]#PH                  R8H  R4      R  4       t&R! t'R" t(R# t)R$ t*R% t+]P:                  ! ],! 4       R&4      R' 4       t-R( t.]P^                  ! R)R*4      R+ 4       t0R, t1R- t2R.t3V t4R/# )0BasicSocketTestsi@  c                   \         P                   \         P                   \         P                   \         P                   \         P
                   \         P                   \         P                   V P                  \         P                  R 4       V P                  \         P                  R 4       V P                  \         P                  R 4       V P                  \         P                  R 4       \         P                   \         P                   \         P                   \         P                    \         P"                   \         P$                   V P                  \         P&                  \         P(                  4       R# TN)r   r   CERT_OPTIONALCERT_REQUIREDr+   r)   r*   r(   assertEqualHAS_SNIHAS_ECDHHAS_TLSv1_2HAS_TLSv1_3OP_NO_SSLv2OP_NO_SSLv3OP_NO_TLSv1OP_NO_TLSv1_3OP_NO_TLSv1_1OP_NO_TLSv1_2rG   PROTOCOL_SSLv23selfs   &r   test_constantsBasicSocketTests.test_constantsB  s    ''d+t,$/$/))3+>+>?r    c           	        \        \        4       Fe  pVP                  R 4      '       g   K  V P                  VR7      ;_uu_ 4        \	        \        V4      pV P                  V^ RV 24       RRR4       Kg  	  R#   + '       g   i     K|  ; i)OP_optionssl.N)dirr   rE   subTestrF   assertGreaterEqual)r   r   values   &  r   test_optionsBasicSocketTests.test_optionsV  sk    HD??5))T**T*''qD-@ +*  +**s   'A;;Bc           
     
   \         P                  \         P                  \         P                  \         P                  \         P
                  \         P                  .pV FT  pV P                  VR 7      ;_uu_ 4        V P                  \        R4      ;_uu_ 4        RVn
        RRR4       RRR4       KV  	  \        P                  ! V \         P                  4       R#   + '       g   i     LC; i  + '       g   i     K  ; i))ssl_typezimmutable typeN)_ssl_SSLContext
_SSLSocket	MemoryBIOCertificate
SSLSessionSSLErrorr   assertRaisesRegex	TypeErrorr   r   check_disallow_instantiation)r   	ssl_typesr   s   &  r   test_ssl_typesBasicSocketTests.test_ssl_types_  s    OONNOOMM
	 "Hx00++I7GHH%)HN I 10 " 	,,T43C3CD IH 100s$   <C1C#C1C.)C11Dc           	        V P                  \        R 4      ;_uu_ 4        \        P                  ! 4       ;_uu_ 4       p\        P	                  V4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; izpublic constructorN)r   r   socketr   	SSLSocketr   ss   & r   test_private_init"BasicSocketTests.test_private_initn  sP    ##I/CDDAa  ! ED  EDDs"   A8A%	A8%A50A88B		c                <   \         P                  pV P                  \        V4      R VP                  ,          4       V P                  \        V4      \        VP                  4      4       \         P                  V4      pV P                  VP                  V4       R# )z$<_SSLMethod.PROTOCOL_TLS_CLIENT: %r>N)	r   rI   r   reprr   rD   rT   assertIsrL   r   protor<   s   &  r   test_str_for_enums#BasicSocketTests.test_str_for_enumss  sj     ''e&Lu{{&Z[US%56nnU#cllE*r    c                   \         P                  4       p\        P                  '       d<   \        P
                  P                  R Y;'       d    R;'       g    R3,          4       V'       d2   \         P                  ^4      pV P                  \        V4      ^4       M/V P                  \         P                  \         P                  ^4       V P                  \        \         P                  R4       \         P                  RR4       \         P                  RR4       \         P                  \        R4      R4       R# )	z
 RAND_status is %d (%s)
zsufficient randomnesszinsufficient randomnesszthis is a random stringg     R@s   this is a random bytes objects!   this is a random bytearray objectN)r   RAND_statusr   rm   rk   rn   ro   
RAND_bytesr   rK   assertRaisesr   r   RAND_add	bytearray)r   vdatas   &  r   test_randomBasicSocketTests.test_random|  s    OO???JJ: !$A$A*A $: $: 9 ;; < >>"%DSY+cllCNNB? 	*cnnb9.55t<YCDdKr    c                   R V n         V P                  \        P                  P	                  \
        4      \        4       V P                  \        P                  P	                  \        4      \        4       \        P                  P	                  \        4      p\        P                  '       dB   \        P                  P                  R\        P                   ! V4      ,           R,           4       V P                  VR,          R4       V P                  VR,          R4       V P                  VR,          R4       V P                  VR,          R	4       R # )
N
subjectAltNameOCSP	caIssuerscrlDistributionPoints))DNSzprojects.developer.nokia.com)r   zprojects.forum.nokia.com)zhttp://ocsp.verisign.com)z0http://SVRIntl-G3-aia.verisign.com/SVRIntlG3.cer)z0http://SVRIntl-G3-crl.verisign.com/SVRIntlG3.crl)maxDiffr   r   r   _test_decode_certCERTFILECERTFILE_INFOr   SIGNED_CERTFILE_INFO	NOKIACERTr   rm   rk   rn   ro   pprintpformatr   ps   & r   test_parse_cert BasicSocketTests.test_parse_cert  s     	HH&&x0	
 	HH&&7 	
 HH&&y1???JJTFNN1$55<=+,?	
 	6$AB;N	P23N	Pr    c                :   \         P                  P                  \        4      p\        P
                  '       dB   \        P                  P                  R \        P                  ! V4      ,           R ,           4       V P                  VRRRRRRRRRRR	RR
^/4       R# )r   issuernotAfterzJun 14 18:00:58 2028 GMT	notBeforezJun 18 18:00:58 2018 GMTserialNumber02subjectr   rW   N))countryNameUK))
commonNamezcody-ca)r  ))r  #codenomicon-vm-2.test.lal.cisco.com))r   r  )r   r   r   TALOS_INVALID_CRLDPr   rm   rk   rn   ro   r   r   r   r   s   & r   test_parse_cert_CVE_2019_5010.BasicSocketTests.test_parse_cert_CVE_2019_5010  s    HH&&':;???JJTFNN1$55<= L67 H ! #E1	
r    c                   \         P                  P                  \        4      p\        P
                  '       dB   \        P                  P                  R \        P                  ! V4      ,           R ,           4       RpV P                  VR,          V4       V P                  VR,          V4       \         P                  R8  d   RpMRpV P                  VR,          V4       R# )	r   r  r   r   N)))r  US))stateOrProvinceNameOregon))localityName	Beaverton)organizationNamezPython Software Foundation))organizationalUnitNamezPython Core Development))r  znull.python.org example.org))emailAddresszpython-dev@python.org)r   	      )r   zaltnull.python.org example.comemailz null@python.org user@example.orgURIz)http://null.python.org http://example.org
IP Addressz	192.0.2.1)r  z2001:DB8:0:0:0:0:0:1)r  r  r  r  )r  z	<invalid>)r   r   r   NULLBYTECERTr   rm   rk   rn   ro   r   r   r   _OPENSSL_API_VERSION)r   r   r  sans   &   r   test_parse_cert_CVE_2013_4238.BasicSocketTests.test_parse_cert_CVE_2013_4238  s    HH&&|4???JJTFNN1$55<=A 	9w/8g.##y0;C0C 	+,c2r    c                ~    \         P                  P                  \        4      pV P	                  VR ,          R4       R# )r   N)
)r   allsans	othernamez<unsupported>r&  )r  zuser@example.org)r   zwww.example.org)DirName)))r  XY))r  zCastle Anthraxr  ))r  zdirname example)r  zhttps://www.python.org/)r  	127.0.0.1)r  z0:0:0:0:0:0:0:1)zRegistered IDz	1.2.3.4.5)r   r   r   
ALLSANFILEr   r   s   & r   test_parse_all_sans$BasicSocketTests.test_parse_all_sans  s1    HH&&z2+,	
r    c                P   \        \        R 4      ;_uu_ 4       pVP                  4       pRRR4       \        P	                  X4      p\        P                  V4      p\        P	                  V4      pV P                  W54       VP                  \        P                  R,           4      '       g   V P                  RV,          4       VP                  R\        P                  ,           R,           4      '       g   V P                  RV,          4       R# R#   + '       g   i     L; i)rNr   z-DER-to-PEM didn't include correct header:
%r
z-DER-to-PEM didn't include correct footer:
%r
)r0   CAFILE_CACERTr1   r   PEM_cert_to_DER_certDER_cert_to_PEM_certr   rE   
PEM_HEADERfailendswith
PEM_FOOTER)r   r3   pemd1p2d2s   &     r   test_DER_to_PEM BasicSocketTests.test_DER_to_PEM  s    -%%&&(C &%%c*%%b)%%b) }}S^^d233IIG"LM{{4#..04788IIG"LM 9 &%s   DD%	c                :   \         P                  p\         P                  p\         P                  pV P	                  V\
        4       V P	                  V\        4       V P	                  V\        4       V P                  VR 4       V P                  VR4       Vw  rErgpV P                  V^4       V P                  V^4       V P                  V^ 4       V P                  VR4       V P                  V^ 4       V P                  VR4       V P                  V^ 4       V P                  V^?4       V P                  V^ 4       V P                  V^4       RVR 2p	V^8  d   RVR RVR RVR 2p
MRVR RVR RVR 2p
V P                  W:V	R3V\        V4      34       R# )	i i   @   z	LibreSSL dzOpenSSL .zAWS-LCN)r   OPENSSL_VERSION_NUMBEROPENSSL_VERSION_INFOOPENSSL_VERSIONassertIsInstanceinttuplerD   r   
assertLessassertLessEqualassertStartsWithhex)r   ntr   majorminorfixpatchstatuslibressl_veropenssl_vers   &          r   test_openssl_version%BasicSocketTests.test_openssl_version  s   &&$$a%a'a% 	:.:&+,(c&q)q!q)s#Q'S!q)UB'*VR("5),A:$U1IQuQiqq	BK$U1IQuQiqQ@K\84AK	
r    c                @   \         P                   ! \         P                  4      p\        V4      p\        P                  ! V4      p\
        P                  ! R \        34      ;_uu_ 4        ?RRR4       V P                  V! 4       R4       R#   + '       g   i     L); i N)	r   AF_INETr   weakrefrefr
   check_warningsResourceWarningr   )r   r   sswrs   &   r   test_refcycleBasicSocketTests.test_refcycle$  sh     MM&..)a [[_++R,ABB Ct$ CBs   *BB	c           
        \         P                   ! \         P                  4      p\        V4      ;_uu_ 4       pV P                  \        VP
                  ^4       V P                  \        VP                  \        R4      4       V P                  \        VP                  ^4       V P                  \        VP                  \        R4      ^4       V P                  \        VP                  R4       V P                  \        VP                  RR4       V P                  \        VP                  4       V P                  \        VP                  R.R^ R4       V P                  \        VP                  ^d4       V P                  \        VP                   \        ^d4      .4       RRR4       R#   + '       g   i     R# ; i)      xN)z0.0.0.0r   r@   )r   rY  r   r   OSErrorrecv	recv_intor   recvfromrecvfrom_intosendsendtoNotImplementedErrordupsendmsgrecvmsgrecvmsg_intor   r   r^  s   &  r   test_wrapped_unconnected)BasicSocketTests.test_wrapped_unconnected/  s3    MM&..)a  Bgrww2gr||Yt_Egr{{A6gr'7'74!Lgrww5gryy$G1266:12::#fb!^=12::sC12??(~.0 !   s   E,F..F?	c                    R Fs  p\         P                   ! \         P                  4      pVP                  V4       \        V4      ;_uu_ 4       pV P	                  WP                  4       4       R R R 4       Ku  	  R #   + '       g   i     K  ; i)N)Ng              @)r   rY  
settimeoutr   r   
gettimeout)r   timeoutr   r^  s   &   r   test_timeoutBasicSocketTests.test_timeoutA  sa     (Gfnn-ALL!!!$$  --/: %$ ( %$$s    A<<Bc           
        \         P                  \         P                  \         P                  \         P                  .p\         P
                  \         P                  \         P                  \         P                  .p\         P                  P                  \         P                  P                  \         P                  P                  .pV F  pV P                  VR 7      ;_uu_ 4        \         P                  \         P                  4      pV P!                  \"        4      ;_uu_ 4       pV;P$                  V,          un        RRR4       V P'                  R\)        XP*                  4      4       RRR4       K  	  V F  p\-        V4      '       g   K  V P                  VR7      ;_uu_ 4        V P!                  \"        4      ;_uu_ 4       p\         P                  V4       RRR4       V P'                  RVP.                   R2\)        XP*                  4      4       RRR4       K  	  V F  p\1        V4      '       g   K  V P                  VR7      ;_uu_ 4        \         P                  \         P                  4      pV P!                  \"        4      ;_uu_ 4       pWn        RRR4       VP4                  P6                  : RVP.                  : 2p	V P'                  RV	 R2\)        XP*                  4      4       RRR4       K  	  R#   + '       g   i     EL; i  + '       g   i     EKd  ; i  + '       g   i     ELY; i  + '       g   i     EK  ; i  + '       g   i     L; i  + '       g   i     EKU  ; i)r   Nz4ssl.OP_NO_SSL*/ssl.OP_NO_TLS* options are deprecated)rL   r   z is deprecated)rW   r@  )r   r   r   r   r   PROTOCOL_TLSv1PROTOCOL_TLSv1_1PROTOCOL_TLSv1_2rG   r   SSLv3TLSv1r8   r   rT   rI   assertWarnsDeprecationWarningoptionsr   rD   warningrM   r   rJ   r6   	__class____name__)
r   r  	protocolsversionsr   r<   cmrL   rW   version_texts
   &         r   test_openssl111_deprecations-BasicSocketTests.test_openssl111_deprecationsJ  so   OO	
     	
	 NN  NN  NN""
 FV,,nnS%<%<=%%&899RKK6)K :  J

O	 -,  "H#H--x00%%&899RNN8, :  8==/8

O 10 "  G"7++g..nnS%<%<=%%&899R*1' :*1*;*;*D*DgllS  <.7

O /.  % :99 -,, :99 100 :9 /..so   )AL*L
-L/ML3#;MAM/M$AM/
L	LL03M>	MMM,'M//Nc                   \         P                  P                  \         P                  P                  \        4      ;'       g    \         P
                  RV4      p\        P                  ! 4       pV P                  VP                  4       V P                  \        P                  4      ;_uu_ 4        \        VVR7       RRR4       R#   + '       g   i     R# ; i)z;Check that trying to use the given client certificate failsr   r   N)r   r   r   r   r   curdirr   
addCleanupcloser   r   r   r   r   r   r   s   && r   bad_cert_testBasicSocketTests.bad_cert_test  s    77<< 9 F FRYY *H6}}

#s||,,T&.0 -,,,s   2C

C	c                (    V P                  R4       R# )z Wrapping with an empty cert filer%   Nr  r   s   &r   test_empty_cert BasicSocketTests.test_empty_cert  s    >*r    c                (    V P                  R4       R# )z:Wrapping with a badly formatted certificate (syntax error)r&   Nr  r   s   &r   test_malformed_cert$BasicSocketTests.test_malformed_cert  s    =)r    c                (    V P                  R4       R# )z2Wrapping with a badly formatted key (syntax error)r'   Nr  r   s   &r   test_malformed_key#BasicSocketTests.test_malformed_key  s    <(r    c           
        \         P                  \         P                  4      p\        P                  ! 4       ;_uu_ 4       pV P	                  \
        VP                  VR RR7       RRR4       R#   + '       g   i     R# ; i)Tzsome.hostnamer   N)r   rT   rH   r   r   r   r   )r   r<   r   s   &  r   test_server_side!BasicSocketTests.test_server_side  sQ    nnS445]]__j#//4.=  ? ___s   %A00B	c           	        \         P                  ! R4      p\         P                   ! \         P                  4      pVP                  VP	                  4       4       \        VRR7      ;_uu_ 4       pV P                  \        4      ;_uu_ 4        VP                  R4       RRR4       RRR4       VP                  4        R#   + '       g   i     L*; i  + '       g   i     L5; i)r*  Fdo_handshake_on_connectzunknown-typeNr*  r   )
r   create_serverrY  connectgetsocknamer   r   r   get_channel_bindingr  )r   r   cr^  s   &   r   test_unknown_channel_binding-BasicSocketTests.test_unknown_channel_binding  s      !12MM&..)			!--/"a??2"":..&&~6 / @ 	
	 /. @?s$   /CC	CCCC$	
tls-unique*'tls-unique' channel binding not availablec                   \         P                   ! \         P                  4      p\        V4      ;_uu_ 4       pV P                  VP	                  R 4      4       RRR4       \         P                   ! \         P                  4      p\        VR\
        R7      ;_uu_ 4       pV P                  VP	                  R 4      4       RRR4       R#   + '       g   i     Ly; i  + '       g   i     R# ; i)r  NT)r   r   )r   rY  r   assertIsNoner  r   rq  s   &  r   test_tls_unique_channel_binding0BasicSocketTests.test_tls_unique_channel_binding  s     MM&..)a  Bb44\BC ! MM&..)aTHEEb44\BC FE	 !  FEEs   !C
!C
C	C.	c                   \        \        P                  ! \        P                  4      4      p\        V4      pV P	                  \
        4      ;_uu_ 4       pR p\        P                  ! 4        R R R 4       V P                  V\        XP                  P                  ^ ,          4      4       R #   + '       g   i     LH; ir?   )r   r   rY  r   r  r]  r   
gc_collectassertInrD   r  r]   )r   r^  r/  r  s   &   r   test_dealloc_warn"BasicSocketTests.test_dealloc_warn  sv    fmmFNN;<Ho.."B  / 	aRZZ__Q/01 /.s   B..B>	c                   \         P                  4       pV P                  \        V4      ^4       V P	                  V\         P
                  4       \        P                  ! 4       ;_uu_ 4       p\        VR&   \        VR&   \         P                  4       pV P                  VP                  \        4       V P                  VP                  \        4       RRR4       R#   + '       g   i     R# ; i)   SSL_CERT_DIRSSL_CERT_FILEN)r   get_default_verify_pathsr   rK   rD  DefaultVerifyPathsr   EnvironmentVarGuardCAPATHr   cafiler"   )r   pathsenvs   &  r   test_get_default_verify_paths.BasicSocketTests.test_get_default_verify_paths  s    ,,.UQ'eS%;%;<**,,"(C#+C 002EU\\84U\\62 -,,,s   -A'CC/	r   Windows specificc                <   V P                  \        P                  R 4      4       V P                  \        P                  R4      4       V P                  \        \        P                  4       V P                  \
        \        P                  R4       \        4       pR F  p\        P                  V4      pV P                  V\        4       V F  pV P                  V\        4       V P                  \        V4      ^4       Vw  rVpV P                  V\        4       V P                  VRR04       V P                  V\        \        \        34       \!        V\        \        34      '       g   K  VP#                  V4       K  	  K  	  RpV P                  W4       R# )CAROOTrX  x509_asn
pkcs_7_asn1.3.6.1.5.5.7.3.1N)r  r  )
assertTruer   enum_certificatesr   r   WindowsErrorsetrD  listrF  r   rK   bytesr  	frozensetboolrC   update)	r   
trust_oids	storenamestoreelementcertenctrust
serverAuths	   &        r   test_enum_certificates'BasicSocketTests.test_enum_certificates  s4   --d34--f56)S%:%:;,(=(=rBU
'I)))4E!!%. %%gu5  Wq1#* 5%%dE2cJ#=>%%eid-CDei%566%%e, ! ( )
j-r    c                   V P                  \        P                  R 4      4       V P                  \        \        P                  4       V P                  \
        \        P                  R4       \        P                  R 4      pV P                  V\        4       V Fl  pV P                  V\        4       V P                  \        V4      ^4       V P                  V^ ,          \        4       V P                  V^,          RR04       Kn  	  R# )r  rX  r  r  N)r  r   	enum_crlsr   r   r  rD  r  rF  r   rK   r  r  )r   crlsr  s   &  r   test_enum_crlsBasicSocketTests.test_enum_crls  s    d+,)S]]3,r:}}T"dD)G!!'51S\1-!!'!*e4MM'!*z<&@A	 r    c                "   R
p\         P                  R4      pV P                  W!4       V P                  VP                  ^4       V P                  VP                  R4       V P                  VP
                  R4       V P                  VP                  R4       V P                  V\         P                  4       V P                  \        \         P                  R4       \         P                  P                  ^4      pV P                  W!4       V P                  V\         P                  4       V P                  \        \         P                  P                  R4       V P                  \        R4      ;_uu_ 4        \         P                  P                  R4       RRR4       \        R4       F  p \         P                  P                  V4      pV P                  VP                  \        4       V P                  VP                  \        4       V P                  VP
                  \        4       V P                  VP                  \        \        R4      34       K  	  \         P                  P!                  R4      pV P                  W!4       V P                  V\         P                  4       V P                  \         P                  P!                  R4      V4       V P                  \         P                  P!                  R4      V4       V P                  \        R4      ;_uu_ 4        \         P                  P!                  R	4       RRR4       R#   + '       g   i     EL; i  \         d     EK  i ; i  + '       g   i     R# ; i)   r  TLS Web Server Authenticationr  zunknown NID 100000i N  zunknown object 'serverauth'
serverauth)r  r  r  r  )r   _ASN1Objectr   nid	shortnamelongnameoidrD  r   r   fromnidr   rangerE  rD   typefromname)r   expectedvaliobjs   &    r   test_asn1object BasicSocketTests.test_asn1object  s|   ) oo12'#&5'FG"56c3??3*coo|Doo%%c*'c3??3*coo&=&=rB##J0DEEOO##F+ FtABoo--a0 %%cggs3%%cmmS9%%cllC8%%cggT$Z/@A  oo&&'FG'c3??311,?J112EF!	###J0MNNOO$$\2 ON' FEE
   ONNs*   ; M2M*, M=M'	*M:9M:=N	c                R   \         P                  R 4      pV P                  \         P                  P                  \         P                  4       V P                  \         P                  P                  V4       V P                  \         P                  P                  P                  ^4       V P                  \         P                  P                  P                  R4       V P                  \         P                  P                  P                  R 4       \         P                  R4      pV P                  \         P                  P                  \         P                  4       V P                  \         P                  P                  V4       V P                  \         P                  P                  P                  ^4       V P                  \         P                  P                  P                  R4       V P                  \         P                  P                  P                  R4       R# )r  r  z1.3.6.1.5.5.7.3.2
clientAuthN)
r   r  rD  r   SERVER_AUTHr   r  r  r  CLIENT_AUTH)r   r  s   & r   test_purpose_enum"BasicSocketTests.test_purpose_enum  sX   oo12ckk55sG00#60044c:00::LI00441	3 oo12ckk55sG00#60044c:00::LI00441	3r    c                   \         P                   ! \         P                  \         P                  4      pV P                  VP                  4       V P                  \        4      ;_uu_ 4       p\        V\        P                  R 7       RRR4       V P                  \        XP                  4      R4       \        P                  \        P                  4      pV P                  \        4      ;_uu_ 4       pVP                  V4       RRR4       V P                  \        VP                  4      R4       R#   + '       g   i     L; i  + '       g   i     LJ; i)r|   Nz!only stream sockets are supported)r   rY  
SOCK_DGRAMr  r  r   rl  r   r   r   r   rD   rl   rT   rI   r   )r   r   cxr<   s   &   r   test_unsupported_dtls&BasicSocketTests.test_unsupported_dtls&  s    MM&..&*;*;< 233rQ#--8 4R\\*,OPnnS445233rOOA 4R\\*,OP 43 43s   ,D65E	6E		E	c                P    V P                  \        P                  V4      V4       R # r?   )r   r   cert_time_to_seconds)r   
timestring	timestamps   &&&r   cert_time_okBasicSocketTests.cert_time_ok1  s    11*=yIr    c                    V P                  \        4      ;_uu_ 4        \        P                  V4       R R R 4       R #   + '       g   i     R # ; ir?   )r   r   r   r  )r   r  s   &&r   cert_time_failBasicSocketTests.cert_time_fail4  s0    z**$$Z0 +***s	   >A	z)local time needs to be different from UTCc                N    V P                  R R4       V P                  RR4       R# )zMay  9 00:00:00 2007 GMTg   CAJan  5 09:34:43 2018 GMT  ѓAN)r
  r   s   &r   "test_cert_time_to_seconds_timezone3BasicSocketTests.test_cert_time_to_seconds_timezone8  s&    
 	4lC4lCr    c                   R pRpV P                  W4       V P                  \        P                  VR7      V4       V P                  RV4       V P                  RV4       V P	                  R4       V P	                  R4       V P	                  R4       V P	                  R4       V P	                  R	4       V P	                  R
4       V P	                  R4       RpV P                  RV4       V P                  RV4       V P                  RR4       V P                  RR4       V P                  RR4       V P	                  R4       V P                  RR4       R# )r  r  )	cert_timezJan 05 09:34:43 2018 GMTzJaN  5 09:34:43 2018 GmTzJan  5 09:34 2018 GMTzJan  5 09:34:43 2018zJan  5 09:34:43 2018 UTCzJan 35 09:34:43 2018 GMTzJon  5 09:34:43 2018 GMTzJan  5 24:00:00 2018 GMTzJan  5 09:60:43 2018 GMTg   WAzDec 31 23:59:60 2008 GMTzJan  1 00:00:00 2009 GMTzJan  5 09:34:59 2018 GMTiFOZzJan  5 09:34:60 2018 GMTiFOZzJan  5 09:34:61 2018 GMTiFOZzJan  5 09:34:62 2018 GMTzDec 31 23:59:59 9999 GMTg  MBN)r
  r   r   r  r  )r   r  ts
newyear_tss   &   r   test_cert_time_to_seconds*BasicSocketTests.test_cert_time_to_seconds@  s?   /
*)11J1GL4b94b934236767676767!
4jA4jA4jA4jA4jA67 	4nEr    LC_ALLrX  c                    R  pV! 4       P                  4       R8X  d   V P                  R4       V P                  RR4       V P                  V! 4       R,           4       R# )c                  0    \         P                  ! R R4      # )z%b)	rc              r  r   r   r   )rt   strftimer@   r    r   local_february_nameNBasicSocketTests.test_cert_time_to_seconds_locale.<locals>.local_february_nameg  s    =='BCCr    febz>locale-specific month name needs to be different from C localezFeb  9 00:00:00 2007 GMTg   `rAz  9 00:00:00 2007 GMTN)lowerskipTestr
  r  )r   r"  s   & r    test_cert_time_to_seconds_locale1BasicSocketTests.test_cert_time_to_seconds_localec  sZ    	D  &&(E1MM 4 5 	4lC/14KKLr    c                ,   \         P                   ! \         P                  4      pV P                  VP                  4       \        P
                  ! V4      p\        \         P                   ! \         P                  4      \        P                  R 7      pV P                  VP                  4       VP                  \        V34      p\        P                  \        P                  \        P                  \        P                  3pV P!                  WE4       R# )r  N)r   rY  r  r  r   	bind_portr   r   r   
connect_exHOSTerrnoECONNREFUSEDEHOSTUNREACH	ETIMEDOUTEWOULDBLOCKr  )r   serverportr   rcerrorss   &     r   test_connect_ex_error&BasicSocketTests.test_connect_ex_errorr  s    v~~.%&&v.V]]6>>:&)&7&79 \\4,'  2 2EOO
 	b!r    c           	        \        4       w  rp\        VR 7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP	                  \
        VP                  34       V P                  VP                  ^ 4      R4       V P                  VP                  R4      ^ 4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r   r  r    N)
r   ThreadedEchoServerr   r   r  r,  r3  r   rf  rj  r   r   r   r   r2  r   s   &     r   test_read_write_zero%BasicSocketTests.test_read_write_zero  s    3B3D0#N;V++FMMO<D , F FIJ		4-.  C0  a0	F VF F VVs$   /CA$C		7C	CCC-	)r   N)5r  
__module____qualname____firstlineno__r   r   r   r   r   r   r   r
  r"  r,  r;  rT  r   cpython_onlyr`  rr  ry  r  r  r  r  r  r  r  r[   
skipUnlessr   CHANNEL_BINDING_TYPESr  r  r  rk   platformr  r  r  r  r  r
  r  rz   r  r  run_with_localer'  r6  r<  __static_attributes____classdictcell____classdict__s   @r   r   r   @  s    @(AE!
+L(P<
*3:
*
N!
F % %0$;3j0+*)? )B)BBEGDGD2
3 02DE. F.0 02DEB FB%3N3"	QJ1 DFDFD!FF Xr*M +M" 	1 	1r    r   c                   p  a  ] tR tRt o R tR t]P                  ! ]^8H  R4      R 4       t	R t
R tR tR	 t]R
 4       t]P                  ! ]! ]P$                  R4      R4      R 4       tR tR tR tR tR tR tR t]P                  ! ]P6                  R4      R 4       tR tR tR tR t R t!]PD                  ! ]#PH                  R8H  R4      R 4       t%]P                  ! ]#PH                  R8H  R4      ]PD                  ! ]&PN                  R 4      R! 4       4       t(R" t)R# t*R$ t+R% t,R& t-R' t.R( t/R)t0V t1R*# )+ContextTestsi  c                   \          Fm  p\        V4      '       g   K  \        P                  ! 4       ;_uu_ 4        \        P                  V4      pR R R 4       V P                  XP                  V4       Ko  	  \        P                  ! 4       ;_uu_ 4        \        P                  4       pR R R 4       V P                  XP                  \        P                  4       V P                  \        \        P
                  R4       V P                  \        \        P
                  ^*4       R #   + '       g   i     L; i  + '       g   i     L; i)Nr  )	PROTOCOLSrM   r
   r\  r   rT   r   rL   rG   r   r   )r   rL   r<   s   &  r   test_constructorContextTests.test_constructor  s    !H))$3355..2C 6  x8	 "
 ++--.."C .s'7'78*cnnb9*cnnb9 65 .-s   D(D;(D8;E	c                <   \         P                  \         P                  4      pVP                  R 4       VP                  R4       V P	                  \         P
                  R4      ;_uu_ 4        VP                  R4       RRR4       R#   + '       g   i     R# ; i)ALLDEFAULTNo cipher can be selected^$:,;?*'dorothyxN)r   rT   rI   r:   r   r   r   r<   s   & r   test_ciphersContextTests.test_ciphers  sc    nnS445	"##CLL2MNNOO./ ONNNs   .B

B	z+Test applies only to Python default ciphersc                D   \         P                  \         P                  4      pVP                  4       pV Ff  pVR ,          pV P	                  RV4       V P	                  RV4       V P	                  RV4       V P	                  RV4       V P	                  RV4       Kh  	  R# )r   PSKSRPMD5RC43DESN)r   rT   rI   get_ciphersassertNotIn)r   r<   r~   suiter   s   &    r   test_python_ciphers ContextTests.test_python_ciphers  s     nnS445//#E=DUD)UD)UD)UD)VT* r    c           
     @   \         P                  \         P                  4      pVP                  R 4       \	        R VP                  4        4       4      p0 RmpVP                  V4      pV P                  \        V4      ^R\        V4       R\        V4       24       R# )AESGCMc              3   2   "   T F  qR ,          x  K  	  R# 5i)r   Nr@   ).0r?  s   & r   	<genexpr>0ContextTests.test_get_ciphers.<locals>.<genexpr>  s     9'8!fII'8s   z
got: z
expected: N>   AES128-GCM-SHA256AES256-GCM-SHA384DHE-RSA-AES128-GCM-SHA256DHE-RSA-AES256-GCM-SHA384ECDHE-RSA-AES128-GCM-SHA256ECDHE-RSA-AES256-GCM-SHA384ECDHE-ECDSA-AES128-GCM-SHA256ECDHE-ECDSA-AES256-GCM-SHA384)
r   rT   rI   r:   r  r^  intersectionr   rK   sorted)r   r<   namesr  rq  s   &    r   test_get_ciphersContextTests.test_get_ciphers  s    nnS445!9s'899	
 ))(3qGF5M?,vhGWFX"Y	
r    c                   \         P                  \         P                  4      p\         P                  \         P                  ,          \         P
                  ,          pV\        \        ,          \        ,          \        ,          \        ,          ,          pV P                  W!P                  4       \        P                  ! 4       ;_uu_ 4        V;P                  \         P                  ,          un        R R R 4       V P                  V\         P                  ,          VP                  4       \        P                  ! 4       ;_uu_ 4        VP                  \         P                  ( ,          Vn        R R R 4       V P                  W!P                  4       ^ Vn        V P                  ^ VP                  \         P
                  ( ,          4       V P!                  \"        4      ;_uu_ 4        RVn        R R R 4       V P!                  \$        4      ;_uu_ 4        ^^d,          Vn        R R R 4       V P!                  \&        4      ;_uu_ 4        RVn        R R R 4       R #   + '       g   i     ELs; i  + '       g   i     EL	; i  + '       g   i     L; i  + '       g   i     Lz; i  + '       g   i     R # ; i)Nabcr  )r   rT   rI   OP_ALLr   r   r(   r+   r)   r*   r,   r   r  r
   r\  r   r   r   OverflowErrorr   )r   r<   defaults   &  r   r   ContextTests.test_options  s   nnS445::/#//A%(CC$%'9:./ 	0 	++. ++--KK3??*K .3??2CKK@ ++--;;#//)99CK .++. CKK3??*::; z**CK +}--s(CK .y))CK *)' .--
 .-- +*--)))s<   (I!(I5.J	JJ/!I2	5J		J	J,	/K 	c                2   \         P                  ! 4       ;_uu_ 4        \        P                  \        P                  4      pR R R 4       V P                  XP                  \        P                  4       \        P                  Vn        V P                  VP                  \        P                  4       \        P                  Vn        V P                  VP                  \        P                  4       \        P                  Vn        V P                  VP                  \        P                  4       V P                  \        4      ;_uu_ 4        R Vn        R R R 4       V P                  \        4      ;_uu_ 4        ^*Vn        R R R 4       \        P                  \        P                  4      pV P                  VP                  \        P                  4       V P                  VP                  4       \        P                  \        P                   4      pV P                  VP                  \        P                  4       V P#                  VP                  4       R #   + '       g   i     EL$; i  + '       g   i     EL$; i  + '       g   i     EL; ir?   )r
   r\  r   rT   rG   r   r   r   r   r   r   r   r   rH   assertFalser   rI   r  rU  s   & r   test_verify_mode_protocol&ContextTests.test_verify_mode_protocol  s   ++--..!1!12C . 	#--8++#*;*;<++#*;*;<--#--8y))"CO *z** CO + nnS445#--8++,nnS445#*;*;<**++ .-- *))***s#   $II1;JI.	1J	J	c                    \         P                  \         P                  4      pV P                  VP                  4       \         P
                  '       di   R Vn        V P                  VP                  4       RVn        V P                  VP                  4       R Vn        V P                  VP                  4       R# V P                  \        4      ;_uu_ 4        R Vn        RRR4       R#   + '       g   i     R# ; i)TFN)	r   rT   rI   r  hostname_checks_common_nameHAS_NEVER_CHECK_COMMON_NAMEr}  r   AttributeErrorrU  s   & r    test_hostname_checks_common_name-ContextTests.test_hostname_checks_common_name  s    nnS445778***.2C+OOC;;<.3C+S<<=.2C+OOC;;<"">2226/ 3222s   C,,C=	c                	   \         P                  \         P                  4      p\         P                  P                  \         P                  P
                  \         P                  P                  0p\         P                  P                  \         P                  P                  0pV P                  VP                  V4       V P                  VP                  V4       \         P                  P                  Vn
        \         P                  P                  Vn        V P                  VP                  \         P                  P                  4       V P                  VP                  \         P                  P                  4       \         P                  P                  Vn
        \         P                  P
                  Vn        V P                  VP                  \         P                  P                  4       V P                  VP                  \         P                  P
                  4       \         P                  P                  Vn        V P                  VP                  \         P                  P                  4       \         P                  P                  Vn        V P                  VP                  \         P                  P
                  \         P                  P                  \         P                  P                  04       \         P                  P                  Vn
        V P                  VP                  \         P                  P                  \         P                  P                  04       V P                  \         4      ;_uu_ 4        ^*Vn
        RRR4       \#        \         P$                  4      '       Ed    \         P                  \         P$                  4      pV P                  VP                  V4       V P                  VP                  \         P                  P                  4       V P                  \         4      ;_uu_ 4        \         P                  P                  Vn
        RRR4       V P                  \         4      ;_uu_ 4        \         P                  P
                  Vn        RRR4       R# R#   + '       g   i     EL2; i  + '       g   i     Lm; i  + '       g   i     R# ; i)*   N)r   rT   rH   r   rU   r  rS   rV   TLSv1_3r  r6   rP   r8   r   r  r   r   rM   r}  )r   r<   minimum_rangemaximum_ranges   &   r   test_min_max_version!ContextTests.test_min_max_version  s@   nnS445
 NN,,NN  NN""
 NN,,NN""	
 		
 		
 "nn44!nn44!7!7	
 	!7!7	
 "nn>>!nn22!A!A	
 	!5!5	
 "nn>>!A!A	
 "nn>>^^!!3>>#9#93>>;O;OP	

 "nn>>^^##S^^%;%;<	

 z**"$C + C0011..!5!56CMM##] ##S^^%E%E "":..&)nn&F&F# /"":..&)nn&:&:# /. 2 +** /....s$   R= S S$=S	S!	$S5	r9   zrequires OpenSSL >= 1.1.0c                    \         P                  \         P                  4      p0 RmpV P                  VP                  V4       R# )r   N>   r   rc  r  r  r  r   )r   rT   rI   r  r9   )r   r<   security_level_ranges   &  r   test_security_level ContextTests.test_security_levelZ  s7    
 nnS445 
 	c((*>?r    c                   \         P                  \         P                  4      p\        \         R ^ 4      pV P	                  VP
                  \         P                  V,          4       \         P                  Vn        V P	                  VP
                  \         P                  4       \         P                  Vn        V P	                  VP
                  \         P                  4       \         P                  Vn        V P	                  VP
                  \         P                  4       \         P                  Vn        V P	                  VP
                  \         P                  4       \         P                  \         P                  ,          Vn        V P	                  VP
                  \         P                  \         P                  ,          4       V P                  \        4      ;_uu_ 4        RVn        RRR4       R#   + '       g   i     R# ; i)VERIFY_X509_TRUSTED_FIRSTN)r   rT   rH   rF   r   verify_flagsVERIFY_DEFAULTVERIFY_CRL_CHECK_LEAFVERIFY_CRL_CHECK_CHAINVERIFY_ALLOW_PROXY_CERTSVERIFY_X509_STRICTr   r   )r   r<   tfs   &  r   test_verify_flagsContextTests.test_verify_flagsm  sZ   nnS445S5q9))3+=+=+BC44))3+D+DE55))3+E+EF--))3+=+=>77))3+G+GH44s7M7MM))22S5K5KK	My))#C *)))s   (G::H	c                   \         P                  \         P                  4      pVP                  \        R R7       VP                  \        \        R7       V P                  \        VP                  \        R7       V P                  \        4      ;_uu_ 4       pVP                  \        4       R R R 4       V P                  XP                  P                  \        P                  4       V P                  \         P                  R4      ;_uu_ 4        VP                  \        4       R R R 4       V P                  \         P                  R4      ;_uu_ 4        VP                  \         4       R R R 4       \         P                  \         P                  4      pVP                  \"        \$        4       VP                  \"        \$        R7       VP                  \&        \(        R7       V P                  \         P                  R4      ;_uu_ 4        VP                  \"        4       R R R 4       V P                  \         P                  R4      ;_uu_ 4        VP                  \$        4       R R R 4       V P                  \         P                  R4      ;_uu_ 4        VP                  \$        \"        R7       R R R 4       \         P                  \         P                  4      p\*        P,                  ! R\*        P.                  4      pV P                  \         P                  V4      ;_uu_ 4        VP                  \0        \$        4       R R R 4       VP                  \2        \4        R7       VP                  \2        \4        P7                  4       R7       VP                  \2        \9        \4        P7                  4       4      R7       VP                  \"        \:        \4        4       VP                  \"        \:        \4        P7                  4       4       VP                  \"        \:        \9        \4        P7                  4       4      4       V P                  \        R4      ;_uu_ 4        VP                  \2        RR7       R R R 4       V P                  \         P                  4      ;_uu_ 4        VP                  \2        RR7       R R R 4       V P                  \<        R	4      ;_uu_ 4        VP                  \2        R
R,          R7       R R R 4       R pR pR pR pR pR p	R p
 ! R R4      pVP                  \2        VR7       VP                  \2        VR7       VP                  \2        VR7       VP                  \2        V! 4       R7       VP                  \2        V! 4       P>                  R7       V P                  \         P                  4      ;_uu_ 4        VP                  \2        VR7       R R R 4       V P                  \<        R	4      ;_uu_ 4        VP                  \2        VR7       R R R 4       V P                  \        R4      ;_uu_ 4        VP                  \2        V	R7       R R R 4       V P                  \@        R4      ;_uu_ 4        VP                  \2        V
R7       R R R 4       VP                  \        V
R7       R #   + '       g   i     EL1; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELX; i  + '       g   i     EL.; i)N)r   PEM (lib|routines)r   r   z|(
            key values mismatch         # OpenSSL
            |
            KEY_VALUES_MISMATCH         # AWS-LC
        ))passwordzshould be a stringTbadpasszcannot be longer   ai  c                      \         # r?   KEY_PASSWORDr@   r    r   getpass_unicode:ContextTests.test_load_cert_chain.<locals>.getpass_unicode  s    r    c                  *    \         P                  4       # r?   )r  encoder@   r    r   getpass_bytes8ContextTests.test_load_cert_chain.<locals>.getpass_bytes  s    &&((r    c                  <    \        \        P                  4       4      # r?   )r   r  r  r@   r    r   getpass_bytearray<ContextTests.test_load_cert_chain.<locals>.getpass_bytearray  s    \00233r    c                      R # )r  r@   r@   r    r   getpass_badpass:ContextTests.test_load_cert_chain.<locals>.getpass_badpass  s    r    c                      R R,          # )r  i   r@   r@   r    r   getpass_huge7ContextTests.test_load_cert_chain.<locals>.getpass_huge  s    ;''r    c                      ^	# )r  r@   r@   r    r   getpass_bad_type;ContextTests.test_load_cert_chain.<locals>.getpass_bad_type  s    r    c                      \        R 4      h)getpass error)	Exceptionr@   r    r   getpass_exception<ContextTests.test_load_cert_chain.<locals>.getpass_exception  s    O,,r    c                   ,   a  ] tR tRt o R tR tRtV tR# ):ContextTests.test_load_cert_chain.<locals>.GetPassCallablei  c                    \         # r?   r  r   s   &r   __call__CContextTests.test_load_cert_chain.<locals>.GetPassCallable.__call__      ##r    c                    \         # r?   r  r   s   &r   getpassBContextTests.test_load_cert_chain.<locals>.GetPassCallable.getpass  r  r    r@   N)r  r>  r?  r@  r  r  rF  rG  rH  s   @r   GetPassCallabler    s     $$ $r    r  zmust return a stringr  )!r   rT   rH   r   r   r   r   re  NONEXISTINGCERTr   rl   r-  ENOENTr   r   BADCERT	EMPTYCERTONLYCERTONLYKEYBYTES_ONLYCERTBYTES_ONLYKEYrecompileXr0  CERTFILE_PROTECTEDr  r  r   ONLYKEY_PROTECTEDr   r  r  )r   r<   r  regexr  r  r  r  r  r  r  r  s   &           r   test_load_cert_chain!ContextTests.test_load_cert_chain  sw   nnS445Hd3Hh7)S%8%8(Kw''20 (++U\\:##CLL2FGG( H##CLL2FGG	* H nnS445Hg.Xw?^]K##CLL2FGG) H##CLL2FGG( H##CLL2FGG(C H nnS445

  dd	
 ##CLL%88w7 9 	.F.9L9L9NO.%.|/B/B/D%E 	 	GH&7FH&79L9L9NOH&7%l&9&9&;<	>##I/CDD 2TB Es||,, 2YG -##J0BCC  2TF]K	 D	 	)	4		(		-	$ 	$
 	.I.G.9JK.9JK.%4%6%>%> 	 	@s||,, 2_M -##J0BCC 2\J D##I/EFF 2=MN G##I?? 2=NO @ 	H/@Ac ('' HGGGGG HGGGGGGGG 988 EDD,,,CCC> -,,CCCFFF???s   [[+[?\\'\;2]+]#2]70^$^"^3 __[(	+[<	?\	\$	'\8	;]	] 	#]4	7^	^	^0	3_	_	_,	c                   \         P                  \         P                  4      pVP                  \        4       VP                  \        R R7       VP                  \
        4       VP                  \
        R R7       V P                  \        VP                  4       V P                  \        VP                  R R R 4       V P                  \        4      ;_uu_ 4       pVP                  \        4       R R R 4       V P                  XP                  P                  \        P                  4       V P                  \         P                  R4      ;_uu_ 4        VP                  \         4       R R R 4       VP                  \        \"        4       VP                  \        \$        R7       V P                  \        VP                  R R4       R #   + '       g   i     L; i  + '       g   i     L|; i)N)r  r"   r  r"   T)r   rT   rH   r   r   BYTES_CERTFILEr   r   re  r  r   rl   r-  r  r   r   r  r  BYTES_CAPATHr   r<   r  s   &  r   test_load_verify_locations'ContextTests.test_load_verify_locations  sL   nnS445!!(+!!$!?!!.1!!!E)S%>%>?)S%>%>dDQw''2%%o6 (++U\\:##CLL2FGG%%g. H!!(F3!!(<!@ 	)S%>%>dK (' HGs   GG G	 G0	c                	   \        \        4      ;_uu_ 4       pVP                  4       pR R R 4       \        P	                  X4      p\        \
        4      ;_uu_ 4       pVP                  4       pR R R 4       \        P	                  X4      p\        P                  \        P                  4      pV P                  VP                  4       R,          ^ 4       VP                  VR7       V P                  VP                  4       R,          ^4       VP                  VR7       V P                  VP                  4       R,          ^4       VP                  VR7       V P                  VP                  4       R,          ^4       \        P                  \        P                  4      pRP                  W$34      pVP                  VR7       V P                  VP                  4       R,          ^4       \        P                  \        P                  4      pRVRVRVR.pVP                  RP                  V4      R7       V P                  VP                  4       R,          ^4       \        P                  \        P                  4      pVP                  VR7       VP                  VR7       V P                  VP                  4       R,          ^4       VP                  VR7       V P                  VP                  4       R,          ^4       \        P                  \        P                  4      pRP                  W534      pVP                  VR7       V P                  VP                  4       R,          ^4       \        P                  \        P                  4      pV P                  \        VP                  \        R7       V P                  \        P                   R	4      ;_uu_ 4        VP                  R
R7       R R R 4       V P                  \        P                   R4      ;_uu_ 4        VP                  RR7       R R R 4       V P                  \        P                   4      ;_uu_ 4        VP                  VR,           R7       R R R 4       R #   + '       g   i     ELq; i  + '       g   i     EL@; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R # ; i)Nx509_cacadatar   headotheragaintailr    z4no start line: cadata does not contain a certificatebrokenz6not enough data: cadata does not contain a certificates   broken   A)r0   r0  r1   r   r1  CAFILE_NEURONIOrT   rI   r   cert_store_statsr   r   r   r   objectr   r   )r   r3   
cacert_pem
cacert_derneuronio_pemneuronio_derr<   combineds   &       r   test_load_verify_cadata$ContextTests.test_load_verify_cadata  s   -  AJ !--j9
/""a668L #//= nnS445--/	:A>!!!4--/	:A>!!!6--/	:A>!!!6--/	:A> nnS44599j78!!!2--/	:A> nnS445Jw &*!!8)<!=--/	:A> nnS445!!!4!!!6--/	:A>!!!4--/	:A> nnS44588Z67!!!2--/	:A> nnS445)S%>%>vN##LLB
 
 %%X%6	

 ##LLD
 
 %%Y%7	

 s||,,%%Z$->%? -,y !   #""^
 


 

 -,,s;   RR%(R9+S-SR"	%R6	9S		S	S0	c                4   \         P                  \         P                  4      p VP                  \        4       TP                  \        4       T P                  \        TP                  4       T P                  \        TP                  R4       T P                  \        4      ;_uu_ 4       pTP                  \        4       RRR4       T P                  XP                  P                  \        P                   4       T P                  \         P"                  4      ;_uu_ 4       pTP                  \$        4       RRR4       R#   \
         d     \        '       d   T P                  R 4       h i ; i  + '       g   i     L; i  + '       g   i     R# ; i)"not supported on Win32 debug buildN)r   rT   rH   load_dh_paramsDHFILERuntimeErrorPy_DEBUG_WIN32r&  BYTES_DHFILEr   r   r2   r  r   rl   r-  r  r   r   r  s   &  r   test_load_dh_params ContextTests.test_load_dh_params.  s   nnS445	v&
 	<()S%7%78)S%7%7>011R/ 2++U\\:s||,,x( -,  	~BC	 21 -,,s)   E -E3&FE0E03F	F	c                    \         P                  \         P                  0 FN  p\         P                  V4      pV P	                  VP                  4       R ^ R^ R^ R^ R^ R^ R^ R^ R^ R	^ R
^ /4       KP  	  R# )numberr  connect_goodconnect_renegotiateacceptaccept_goodaccept_renegotiatehitsmissestimeouts
cache_fullN)r   rI   rH   rT   r   session_statsr   s   &  r   test_session_statsContextTests.test_session_stats?  s    --s/F/FGE..'CS..0!1%q!q$a!Aa3  Hr    c                l    \         P                  \         P                  4      pVP                  4        R # r?   )r   rT   rI   set_default_verify_pathsrU  s   & r   test_set_default_verify_paths*ContextTests.test_set_default_verify_pathsP  s$     nnS445$$&r    z#ECDH disabled on this OpenSSL buildc                   \         P                  \         P                  4      pVP                  R 4       VP                  R4       V P	                  \
        VP                  4       V P	                  \
        VP                  R4       V P	                  \        VP                  R4       V P	                  \        VP                  R4       R# )
prime256v1s
   prime256v1Nfoo   foo)r   rT   rH   set_ecdh_curver   r   r   rU  s   & r   test_set_ecdh_curve ContextTests.test_set_ecdh_curveV  s    nnS445<(=))S%7%78)S%7%7>*c&8&8%@*c&8&8&Ar    c                   \         P                  \         P                  4      pV P                  \        VP
                  4       V P                  \        VP
                  ^4       V P                  \        VP
                  R4       V P                  \        VP
                  V4       R pVP                  R4       VP                  V4       R# )r  rX  c                     R # r?   r@   )r   
servernamer<   s   &&&r   dummycallback5ContextTests.test_sni_callback.<locals>.dummycallbacki      r    N)r   rT   rH   r   r   set_servername_callback)r   r<   r  s   &  r   test_sni_callbackContextTests.test_sni_callback`  s    nnS445 	)S%@%@A)S%@%@!D)S%@%@"E)S%@%@#F	##D)##M2r    c                   \         P                  \         P                  4      pV3R  lpVP                  V4       \        P
                  ! V4      p??\        P                  ! 4        V P                  V! 4       R4       R# )c                     R # r?   r@   )r   r  r<   cycles   &&&&r   r  >ContextTests.test_sni_callback_refcycle.<locals>.dummycallbackr  r  r    N)	r   rT   rH   r  rZ  r[  gccollectr   )r   r<   r  r_  s   &   r   test_sni_callback_refcycle'ContextTests.test_sni_callback_refcyclen  sZ     nnS4457: 	##M2[[


bdD!r    c           	        \         P                  \         P                  4      pV P                  VP	                  4       R ^ R^ R^ /4       VP                  \        4       V P                  VP	                  4       R ^ R^ R^ /4       VP                  \        4       V P                  VP	                  4       R ^ R^ R^/4       VP                  \        4       V P                  VP	                  4       R ^R^ R^/4       R# )r  crlx509N)	r   rT   rI   r   r  r   r   r   r0  rU  s   & r   test_cert_store_stats"ContextTests.test_cert_store_statsz  s    nnS445--/5!VQ/	1H%--/5!VQ/	1!!(+--/5!VQ/	1!!-0--/5!VQ/	1r    c                r   \         P                  \         P                  4      pV P                  VP	                  4       . 4       VP                  \        4       V P                  VP	                  4       . 4       VP                  \        4       V P                  VP	                  4       R RRRRRRRRRRRR	^/.4       \        \        4      ;_uu_ 4       pVP                  4       pR
R
R
4       \         P                  X4      pV P                  VP	                  R4      V.4       R
#   + '       g   i     LI; i)r   r   zMar 29 12:29:49 2033 GMTr   zMar 30 12:29:49 2003 GMTr  00r   r  rW   NT)))r  zRoot CA))r  zhttp://www.cacert.org))r  zCA Cert Signing Authority))r  zsupport@cacert.org)z!https://www.cacert.org/revoke.crl)r   rT   rI   r   get_ca_certsr   r   r0  r0   r1   r1  )r   r<   r3   r7  ders   &    r   test_get_ca_certsContextTests.test_get_ca_certs  s   nnS445))+R0!!(+))+R0!!-0))+ D 45d%'M E  	 -  A&&(C !&&s+))$/#7 ! s   D&&D6	c                   \         P                  \         P                  4      pVP                  4        \         P                  \         P                  4      pVP                  \         P                  P
                  4       VP                  4        \         P                  \         P                  4      pVP                  \         P                  P                  4       \         P                  \         P                  4      pV P                  \        VP                  R 4       V P                  \        VP                  R4       R # )Nr  )	r   rT   rI   load_default_certsr   r  r  r   r   rU  s   & r   test_load_default_certs$ContextTests.test_load_default_certs  s    nnS445 nnS445s{{667 nnS445s{{667nnS445)S%;%;TB)S%;%;]Kr    r   znot-Windows specificc                P   \         P                  \         P                  4      p\        P                  ! 4       ;_uu_ 4       p\
        VR &   \        VR&   VP                  4        V P                  VP                  4       R^ R^R^ /4       RRR4       R#   + '       g   i     R# ; i)r  r  r%  r&  r  N)
r   rT   rI   r   r  r  r   r0  r   r  )r   r<   r  s   &  r   test_load_default_certs_env(ContextTests.test_load_default_certs_env  s}    nnS445**,,"(C#+C ""$S113eQ9VW5XY	 -,,,s   A	BB%	r  z3Debug build does not share environment between CRTsc                   \         P                  \         P                  4      pVP                  4        VP	                  4       p\         P                  \         P                  4      p\
        P                  ! 4       ;_uu_ 4       p\        VR &   \        VR&   VP                  4        VR;;,          ^,          uu&   V P                  VP	                  4       V4       RRR4       R#   + '       g   i     R# ; i)r  r  r&  N)
r   rT   rI   r0  r  r   r  r  r   r   )r   r<   statsr  s   &   r   #test_load_default_certs_env_windows0ContextTests.test_load_default_certs_env_windows  s     nnS445 $$&nnS445**,,"(C#+C ""$&MQMS113U; -,,,s   AC&&C7	c                   V P                  VP                  \        P                  ,          \        P                  4       \        ^ 8w  d,   V P                  VP                  \        ,          \        4       \
        ^ 8w  d,   V P                  VP                  \
        ,          \
        4       \        ^ 8w  d,   V P                  VP                  \        ,          \        4       \        ^ 8w  d,   V P                  VP                  \        ,          \        4       T P                  VP                  \        P                  ,          \        '       d	   ^ 4       R# \        P                  4       R# r   N)
r   r  r   r   r(   r)   r*   r+   OP_LEGACY_SERVER_CONNECTrR   rU  s   &&r   _assert_context_options$ContextTests._assert_context_options  s    s6H!S[[+<<.0q S[[+;;-/"S[[+==/1&!+S[[+FF8:s'C'CC..	R474P4P	Rr    c                   \         P                  4       pV P                  VP                  \         P                  4       V P                  VP
                  \         P                  4       V P                  VP                  \         P                  ,          \         P                  4       V P                  VP                  \         P                  ,          \         P                  4       V P                  VP                  4       V P                  V4       \        \        4      ;_uu_ 4       pVP                  4       pR R R 4       \         P                  \        \         XR7      pV P                  VP                  \         P                  4       V P                  VP
                  \         P                  4       V P                  V4       \         P                  \         P"                  P$                  4      pV P                  VP                  \         P&                  4       V P                  VP
                  \         P(                  4       V P                  V4       R #   + '       g   i     EL*; i)N)r  r"   r  )r   create_default_contextr   rL   rI   r   r   r  VERIFY_X509_PARTIAL_CHAINr  r  r   r=  r0   r   r1   r  r   r  rH   r   )r   r<   r3   r  s   &   r   test_create_default_context(ContextTests.test_create_default_context  s   ((*s'>'>?#*;*;<))C,I,II66	8))C,B,BB**	,**+$$S)*VVXF ((
606 ) 8s'>'>?#*;*;<$$S)(()@)@As'>'>?#--8$$S) s   *II-	c                   \         P                  4       pV P                  VP                  \         P                  4       V P                  VP
                  \         P                  4       V P                  VP                  4       V P                  V4       \        \         P                  4      '       d   \        P                  ! 4       ;_uu_ 4        \         P                  \         P                  4      pR R R 4       V P                  VP                  \         P                  4       V P                  VP
                  \         P                  4       V P                  V4       \        P                  ! 4       ;_uu_ 4        \         P                  \         P                  \         P                  RR7      pR R R 4       V P                  VP                  \         P                  4       V P                  VP
                  \         P                  4       V P!                  VP                  4       V P                  V4       \         P                  \         P"                  P$                  R7      pV P                  VP                  \         P&                  4       V P                  VP
                  \         P                  4       V P                  V4       R #   + '       g   i     EL; i  + '       g   i     EL:; i)NT)r|   r   purpose)r   _create_stdlib_contextr   rL   rI   r   r   r}  r   r=  rM   r|  r
   r\  r~  r   r  r   r  rH   rU  s   & r   test__create_stdlib_context(ContextTests.test__create_stdlib_context  s   ((*s'>'>?#--8++,$$S)C..// //11001C1CD 2S\\3+=+=>S__cmm<((-++--,,$$++# - C . 	s';';<#*;*;<**+$$S)((1H1H(Is'>'>?#--8$$S)) 211 .--s   $K?5K%K"	%K6	c                   \         P                  ! 4       ;_uu_ 4        \        P                  \        P                  4      pR R R 4       V P                  XP                  4       V P                  VP                  \        P                  4       RVn        V P                  VP                  4       V P                  VP                  \        P                  4       RVn        \        P                  Vn        V P                  VP                  4       V P                  VP                  \        P                  4       RVn        \        P                  Vn        RVn        V P                  VP                  4       V P                  VP                  \        P                  4       RVn        V P                  VP                  4       V P                  VP                  \        P                  4       RVn        \        P                  Vn        RVn        V P                  VP                  4       V P                  VP                  \        P                  4       RVn        V P                  VP                  4       V P                  VP                  \        P                  4       V P                  \        4      ;_uu_ 4        \        P                  Vn        R R R 4       RVn        V P                  VP                  4       \        P                  Vn        V P                  VP                  \        P                  4       R #   + '       g   i     EL	; i  + '       g   i     L; i)NTF)r
   r\  r   rT   rG   r}  r   r   r   r   r  r   r   r   r   rU  s   & r   test_check_hostname ContextTests.test_check_hostname  sD   ++--..!1!12C .++,#--8 "**+#*;*;<"++++,#*;*;< #--"++,#--8!**+#*;*;<"++"++,#*;*;<!**+#*;*;< z**!mmCO +"++,--#--8S .--H +*s   $MMM	M&	c                   \         P                  \         P                  4      pV P                  VP                  4       V P                  VP                  \         P                  4       \         P                  \         P                  4      pV P                  VP                  4       V P                  VP                  \         P                  4       R # r?   )r   rT   rI   r  r   r   r   r   rH   r}  r   rU  s   & r   test_context_client_server'ContextTests.test_context_client_server@  s    nnS445**+#*;*;< nnS445++,#--8r    c                    ! R  R\         P                  4      p ! R R\         P                  4      p\         P                  \         P                  4      pWn        W#n        VP                  \        P                  ! 4       RR7      ;_uu_ 4       pV P                  WA4       RRR4       VP                  \         P                  4       \         P                  4       RR7      pV P                  WR4       R#   + '       g   i     L[; i)c                       ] tR tRtRtR# );ContextTests.test_context_custom_class.<locals>.MySSLSocketiL  r@   Nr  r>  r?  r@  rF  r@   r    r   MySSLSocketrR  L      r    rT  c                       ] tR tRtRtR# );ContextTests.test_context_custom_class.<locals>.MySSLObjectiO  r@   NrS  r@   r    r   MySSLObjectrW  O  rU  r    rX  Tr   N)r   r   	SSLObjectrT   rH   sslsocket_classsslobject_classr   r   rD  wrap_bior   )r   rT  rX  r<   r   r  s   &     r   test_context_custom_class&ContextTests.test_context_custom_classK  s    	#-- 		#-- 	 nnS445))__V]]_$_??4!!$4 @ll3==?CMMOlNc/ @?s   C55D	c                   \         P                  \         P                  4      pV P                  VP                  ^4       ^Vn        V P                  VP                  ^4       ^ Vn        V P                  VP                  ^ 4       V P                  \        4      ;_uu_ 4        RVn        RRR4       V P                  \        4      ;_uu_ 4        RVn        RRR4       \         P                  \         P                  4      pV P                  VP                  ^4       V P                  \        4      ;_uu_ 4        ^Vn        RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)r  Nr  )	r   rT   rH   r   num_ticketsr   r   r   rI   rU  s   & r   test_num_tickestContextTests.test_num_tickest[  s    nnS445!,!,!,z** CO +y))"CO * nnS445!,z**CO +* +*))
 +**s$   #EE!<E4E	!E1	4F	r@   N)2r  r>  r?  r@  rN  rV  r[   rB  r   ra  rt  r   r~  r  ignore_deprecationr  r7   r   rT   r  r  r  r  r  r  r  r
  r   r  r  r"  r'  r-  r1  skipIfrk   rD  r4  r   Py_DEBUGr8  r=  rB  rH  rK  rN  r^  rb  rF  rG  rH  s   @r   rK  rK    s    
:0 /14FH	+H	+
&  D,07 L; L;\  01#@	@$(WBrL&?@B)""' 'LMB NB3
"188L __S\\W,.DEZ FZ 02DE__W%%JL<L F<R"*2*<*9X	90    r    rK  c                   8   a  ] tR tRt o R tR tR tR tRtV t	R# )SSLErrorTestsim  c                :   \         P                  ^R4      pV P                  \        V4      R4       V P                  VP                  ^4       \         P                  ^R4      pV P                  \        V4      R4       V P                  VP                  ^4       R# )rc  r  N)r   r   r   rD   r-  SSLZeroReturnError)r   es   & r   test_strSSLErrorTests.test_stro  st    LLE"Q'!$""1e,Q'!$r    c                B   \         P                  \         P                  4      p V P                  \         P                  4      ;_uu_ 4       pVP                  \        4       R R R 4       T P                  XP                  P                  R4       RpT P                  TP                  P                  T4       \        TP                  4      pT P!                  RT4       R #   + '       g   i     L; i  \         d     \        '       d   T P                  R4       h i ; i)Nr  PEMz+(NO_START_LINE|UNSUPPORTED_PUBLIC_KEY_TYPE)NO_START_LINE)r   rT   rI   r   r   r  r   r  r  r&  r   rl   libraryassertRegexreasonrD   r  )r   r<   r  r  r   s   &    r   test_lib_reasonSSLErrorTests.test_lib_reasony  s    nnS445	""3<<00B""8, 1 	--u5=,,e4oq) 10 	~BC	s/   'C4 C!"C4 !C1	,C4 1C4 4DDc                0   \         P                  \         P                  4      pR Vn        \         P                  Vn        \        P                  ! R4      ;_uu_ 4       p\        P                  ! VP                  4       4      pVP                  R 4       VP                  VR R R7      ;_uu_ 4       pV P                  \         P                  4      ;_uu_ 4       pVP                  4        RRR4       \        XP                   4      pV P#                  VR4       V P%                  VP                   P&                  \         P(                  4       RRR4       RRR4       R#   + '       g   i     L}; i  + '       g   i     L-; i  + '       g   i     R# ; i)Fr  Nz%The operation did not complete (read)r  )r   rT   rI   r   r   r   r   r  create_connectionr  setblockingr   r   SSLWantReadErrordo_handshakerD   rl   rI  r   r-  SSL_ERROR_WANT_READ)r   r<   r   r  r  s   &    r   test_subclassSSLErrorTests.test_subclass  s    nnS445"--!!"233q((9AMM% E5IIQ&&s';';<<NN$ =%%%a)PQ  !3!3S5L5LM J 43 =< JI 433s>   AF0(E1	E)A#E1	FE.)E1	1F<FF	c                   \         P                  4       pV P                  \        4      ;_uu_ 4        VP	                  \         P                  4       \         P                  4       R R7       RRR4       V P                  \        4      ;_uu_ 4        VP	                  \         P                  4       \         P                  4       RR7       RRR4       V P                  \        4      ;_uu_ 4        VP	                  \         P                  4       \         P                  4       RR7       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)rX  r  Nz.example.orgzexample.org evil.com)r   r@  r   r   r]  r   r   rU  s   & r   test_bad_server_hostname&SSLErrorTests.test_bad_server_hostname  s    ((*z**LL#--/)+  - + z**LL#--/)7  9 + y))LL#--/)B  D *) +* +* *))s#   9D19E.9E1E	E	E(	r@   N)
r  r>  r?  r@  rl  rt  r|  r  rF  rG  rH  s   @r   rh  rh  m  s!     %*"N$
D 
Dr    rh  c                   >   a  ] tR tRt o R tR tR tR tR tRt	V t
R# )	MemoryBIOTestsi  c                |   \         P                  4       pVP                  R 4       V P                  VP	                  4       R 4       V P                  VP	                  4       R4       VP                  R 4       VP                  R4       V P                  VP	                  4       R4       V P                  VP	                  4       R4       VP                  R4       V P                  VP	                  ^4      R4       V P                  VP	                  ^4      R4       V P                  VP	                  ^4      R4       R# )r  r       bars   foobar   bazs   ba   zN)r   r   ro   r   r1   r   bios   & r   test_read_writeMemoryBIOTests.test_read_write  s    mmo		&V,S)		&		&Y/S)		&!e,!d+!c*r    c                   \         P                  4       pV P                  VP                  4       V P	                  VP                  4       R 4       V P                  VP                  4       VP                  R4       V P                  VP                  4       VP                  4        V P                  VP                  4       V P	                  VP                  ^4      R4       V P                  VP                  4       V P	                  VP                  ^4      R4       V P                  VP                  4       V P	                  VP                  4       R 4       V P                  VP                  4       R# )r    r  s   fo   oN)	r   r   r}  eofr   r1   ro   	write_eofr  r  s   & r   test_eofMemoryBIOTests.test_eof  s    mmo!S)!		&!!!e,!!d+ S) r    c                >   \         P                  4       pV P                  VP                  ^ 4       VP	                  R4       V P                  VP                  ^4       \        ^4       F>  pVP                  ^4       V P                  VP                  ^V,
          ^,
          4       K@  	  \        ^4       F7  pVP	                  R4       V P                  VP                  V^,           4       K9  	  VP                  4        V P                  VP                  ^ 4       R# )r   r  rd  N)r   r   r   pendingro   r  r1   )r   r  r  s   &  r   test_pendingMemoryBIOTests.test_pending  s    mmoa(		&a(qAHHQKS[[!A#a%0  qAIIdOS[[!A#.  	
a(r    c                `   \         P                  4       pVP                  R 4       V P                  VP	                  4       R 4       VP                  \        R4      4       V P                  VP	                  4       R4       VP                  \        R4      4       V P                  VP	                  4       R4       \        \        R4      4      pVRRR1,          pV P                  \        4      ;_uu_ 4        VP                  \        V4      4       RRR4       R#   + '       g   i     R# ; i)r  r  r  s	   noncontigN)	r   r   ro   r   r1   r   
memoryviewr   BufferError)r   r  mnoncontig_writables   &   r   test_buffer_types MemoryBIOTests.test_buffer_types  s    mmo		&V,		)F#$V,		*V$%V,y./ttW{++IIj!345 ,+++s   7DD-	c                6   \         P                  4       pV P                  \        VP                  R 4       V P                  \        VP                  R4       V P                  \        VP                  R4       V P                  \        VP                  ^4       R# )r  NT)r   r   r   r   ro   r  s   & r   test_error_typesMemoryBIOTests.test_error_types  se    mmo)SYY6)SYY5)SYY5)SYY2r    r@   N)r  r>  r?  r@  r  r  r  r  r  rF  rG  rH  s   @r   r  r    s#     +! )63 3r    r  c                   ,   a  ] tR tRt o R tR tRtV tR# )SSLObjectTestsi  c                    \         P                  4       pV P                  \        R 4      ;_uu_ 4        \         P	                  W4       RRR4       R#   + '       g   i     R# ; ir   )r   r   r   r   rZ  r  s   & r   r    SSLObjectTests.test_private_init  s=    mmo##I/CDDMM## EDDDs   AA$	c                N   \        4       w  rp\        P                  4       p\        P                  4       p\        P                  4       p\        P                  4       pVP                  WEVR 7      pVP                  WgRR7      p	\	        ^4       F  p
 VP                  4        VP                  '       d    VP                  VP                  4       4        V	P                  4        VP                  '       g   Kj  VP                  VP                  4       4       K  	  VP                  4        V	P                  4        V P                  \        P                  4      ;_uu_ 4        VP                  4        RRR4       VP                  VP                  4       4       V	P                  4        VP                  VP                  4       4       VP                  4        R#   \        P                   d     ELQi ; i  \        P                   d     EL+i ; i  + '       g   i     L; i)r  TrY  N)r   r   r   r]  r  rz  ry  r  ro   r1   r   unwrap)r   
client_ctx
server_ctxr   c_inc_outs_ins_outclientr2  _s   &          r   test_unwrapSSLObjectTests.test_unwrap  s   +:+<(
}}}}$$T($K$$Td$C qA##% }}}

5::<(##% }}}

5::<(  	 s3344MMO 5
 	

5::<  	

5::< 7 ''  ''  54s0   GG8#HG54G58HHH$	r@   N)r  r>  r?  r@  r   r  rF  rG  rH  s   @r   r  r    s     $
( (r    r  c                      a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR t]P                  ! ]P"                  R8H  R4      R 4       tR tR tR tR tR tR tR tR tR tR tR tR tRtV t R# )SimpleBackgroundTestsi  z?Tests that connect to a simple server running in the backgroundc                   \         P                  \         P                  4      V n        V P                  P	                  \
        4       \        V P                  R 7      pV P                  V4       \        VP                  3V n
        R# )r9  N)r   rT   rH   r   r   r   r:  enterContextr,  r3  server_addr)r   r2  s   & r   setUpSimpleBackgroundTests.setUp  s\    !nnS-D-DE++O<#D,?,?@&! &++.r    c                   \        \        P                  ! \        P                  4      \        P                  R 7      ;_uu_ 4       pVP                  V P                  4       V P                  / VP                  4       4       V P                  VP                  4       RRR4       \        \        P                  ! \        P                  4      \        P                  \        R7      ;_uu_ 4       pVP                  V P                  4       V P                  VP                  4       4       V P                  VP                  4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r  Nr|   r}   )r   r   rY  r   r   r  r  r   getpeercertr}  r   r   r   r  r   s   & r   test_connect"SimpleBackgroundTests.test_connect&  s    fmmFNN;&)mm5 589IId&&'R1Q]]+	5 fmmFNN;&)&7&7%/1 145IId&&'OOAMMO,Q]]+1 15 51 1 1s   AE/AE"E	"E3	c                l   \        \        P                  ! \        P                  4      \        P                  R 7      pV P                  VP                  4       \        P                  ! R\        P                  4      pV P                  \        P                  VVP                  V P                  4       R# )r  |(
            certificate verify failed   # OpenSSL
            |
            CERTIFICATE_VERIFY_FAILED   # AWS-LC
        )N)r   r   rY  r   r   r  r  r  r  r  r   r   r  r  )r   r   r  s   &  r   test_connect_fail'SimpleBackgroundTests.test_connect_fail5  sy     V]]6>>:&)&7&79 

  dd	
 	s||U yy$*:*:	<r    c                T   \        \        P                  ! \        P                  4      \        P                  \
        R 7      pV P                  VP                  4       V P                  ^ VP                  V P                  4      4       V P                  VP                  4       4       R# )r  N)r   r   rY  r   r   r   r  r  r   r+  r  r  r  r   s   & r   test_connect_ex%SimpleBackgroundTests.test_connect_exE  sj    V]]6>>:&)&7&7%/1 	 ALL)9)9:;(r    c                   \        \        P                  ! \        P                  4      \        P                  \
        R R7      pV P                  VP                  4       VP                  R 4       VP                  V P                  4      pV P                  V^ \        P                  \        P                  34       \        P                  ! . V.. R4         VP!                  4         T P'                  TP)                  4       4       R#   \        P"                   d    \        P                  ! T.. . R4        Kf  \        P$                   d    \        P                  ! . T.. R4        K  i ; i)F)r|   r}   r  ru  N)r   r   rY  r   r   r   r  r  rx  r+  r  r  r-  EINPROGRESSr1  selectrz  ry  SSLWantWriteErrorr  r  r   r   r4  s   &  r   test_non_blocking_connect_ex2SimpleBackgroundTests.test_non_blocking_connect_exN  s	    V]]6>>:&)&7&7%/49; 	 	e\\$**+b1e//1B1BCDb1#r3'0  	( '' 0qc2r3/(( 0b1#r3/0s   D
 
/E.<E.E.-E.c                   \         P                  \         P                  4      pR Vn        \         P                  Vn        VP                  \        P                  ! \        P                  4      4      ;_uu_ 4       pVP                  V P                  4       V P                  / VP                  4       4       RRR4       VP                  \        P                  ! \        P                  4      RR7      ;_uu_ 4       pVP                  V P                  4       RRR4       \         P                  Vn        VP                  \        4       VP                  \        P                  ! \        P                  4      4      ;_uu_ 4       pVP                  V P                  4       VP                  4       pV P!                  V4       RRR4       R#   + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     R# ; i)FNdummyr  )r   rT   rI   r   r   r   r   r   rY  r  r  r   r  r   r   r   r  r   r<   r   r  s   &   r   test_connect_with_context/SimpleBackgroundTests.test_connect_with_contexth  sG   nnS445"--__V]]6>>:;;qIId&&'R1 < __V]]6>>:,3  5 589IId&&'5 ++!!*-__V]]6>>:;;qIId&&'==?DOOD! <; <;;5 5 <;;s$   ;<G<G =G3G	 G0	3H	c                   \         P                  \         P                  4      pVP                  \        P                  ! \        P
                  4      \        R 7      pV P                  VP                  4       \        P                  ! R\        P                  4      pV P                  \         P                  VVP                  V P                  4       R# )r  r  N)r   rT   rI   r   r   rY  r   r  r  r  r  r  r   r   r  r  )r   r<   r   r  s   &   r   test_connect_with_context_fail4SimpleBackgroundTests.test_connect_with_context_fail|  s     nnS445OOMM&..)4  
 	 

  dd	
 	s||U !		4+;+;	=r    c                P   \         P                  \         P                  4      pVP                  \        R 7       VP                  \        P                  ! \        P                  4      \        R7      ;_uu_ 4       pVP                  V P                  4       VP                  4       pV P                  V4       RRR4       \         P                  \         P                  4      pVP                  \        R 7       VP                  \        P                  ! \        P                  4      \        R7      ;_uu_ 4       pVP                  V P                  4       VP                  4       pV P                  V4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r  r  N)r   rT   rI   r   r  r   r   rY  r   r  r  r  r  r  r  s   &   r   test_connect_capath)SimpleBackgroundTests.test_connect_capath  s.    nnS445!!!0__V]]6>>:-E  G GJKIId&&'==?DOOD!	G nnS445!!!6__V]]6>>:-E  G GJKIId&&'==?DOOD!	G GG GG G Gs   ;=F:=FF	F%	c                   \        \        4      ;_uu_ 4       pVP                  4       pR R R 4       \        P	                  X4      p\        P                  \        P                  4      pVP                  VR7       VP                  \        P                  ! \        P                  4      \        R7      ;_uu_ 4       pVP                  V P                  4       VP                  4       pV P                  V4       R R R 4       \        P                  \        P                  4      pVP                  VR7       VP                  \        P                  ! \        P                  4      \        R7      ;_uu_ 4       pVP                  V P                  4       VP                  4       pV P                  V4       R R R 4       R #   + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     R # ; i)Nr  r  )r0   r   r1   r   r1  rT   rI   r   r   r   rY  r   r  r  r  r  )r   r3   r7  r,  r<   r   r  s   &      r   test_connect_cadata)SimpleBackgroundTests.test_connect_cadata  se   *&&(C &&s+nnS445!!!-__V]]6>>:-E  G GJKIId&&'==?DOOD!	G nnS445!!!-__V]]6>>:-E  G GJKIId&&'==?DOOD!	G G 
G GG G Gs#   F><=G7=G%>G	G"	%G6	ntz*Can't use a socket as a file under Windowsc                v   \        \        P                  ! \        P                  4      4      pVP                  V P                  4       VP                  4       pVP                  4       pVP                  4        \        P                  ! V^ 4       VP                  4        \        P                  ! 4        V P                  \        4      ;_uu_ 4       p\        P                  ! V^ 4       RRR4       V P                  XP                  P                   \         P"                  4       R#   + '       g   i     LF; ir;  )r   r   rY  r  r  filenomakefiler  r   r1   r   r!  r   re  r   rl   r-  EBADF)r   r^  fdr3   rk  s   &    r   test_makefile_close)SimpleBackgroundTests.test_makefile_close  s    
 fmmFNN;<


4##$YY[KKM		
A




w''1GGBN (**EKK8 ('s   D((D8	c                   \         P                   ! \         P                  4      pVP                  V P                  4       VP	                  R 4       \        V\        P                  R R7      pV P                  VP                  4       ^ p  V^,          pVP                  4         \        P                  '       d)   \         P"                  P%                  RT,          4       R# R#   \        P                   d    \        P                  ! T.. . 4        K  \        P                   d    \        P                  ! . T.. 4        K  i ; i)Fr|   r  z9
Needed %d calls to do_handshake() to establish session.
N)r   rY  r  r  rx  r   r   r   r  r  rz  ry  r  r  r   rm   rk   rn   ro   )r   r   counts   &  r   test_non_blocking_handshake1SimpleBackgroundTests.test_non_blocking_handshake  s    MM&..)			$""#	eQ&)mm49; 	 +
 
 ???JJZ]bbc 	 '' +qc2r*(( +b1#r*+s   C& &.EE*EEc                @    \        V .V P                  O5R \        /  R# )r  N)_test_get_server_certificater  r   r   s   &r   test_get_server_certificate1SimpleBackgroundTests.test_get_server_certificate  s    $TND,<,<N:Nr    c           	        a V P                   w  r. oV3R  lpV P                  P                  V4       \        P	                  W34      pV'       g   V P                  RV: RV: R24       \        P	                  W3\        R7      pV'       g   V P                  RV: RV: R24       \        P                  '       d-   \        P                  P                  RV: RV: RV: R24       V P                  SW.4       R# )	c                 *   < SP                  V4       R # r?   )append)ssl_sockserver_nameinitial_contextserver_namess   &&&r   servername_cbLSimpleBackgroundTests.test_get_server_certificate_sni.<locals>.servername_cb  s    ,r    No server certificate on :!r}   
Verified certificate for  is
r   N)r  r   r  r   get_server_certificater4  r   r   rm   rk   rn   ro   r   )r   hostr3  r  r7  r  s   &    @r   test_get_server_certificate_sni5SimpleBackgroundTests.test_get_server_certificate_sni  s    %%
	-33MB(($6II4FG(($
(KII4FG???JJDRVX[\]|4r    c                4    \        V .V P                  O5!   R # r?   )!_test_get_server_certificate_failr  r   s   &r    test_get_server_certificate_fail6SimpleBackgroundTests.test_get_server_certificate_fail  s     	*$B1A1ABr    c                   R  pV P                   P                  V4       V P                  \        P                  4      ;_uu_ 4        \
        P                  V P                  \        RR7       RRR4       R#   + '       g   i     R# ; i)c                 2    \         P                  ! R 4       R# )皙?N)rt   sleepr  r  r  s   &&&r   r  PSimpleBackgroundTests.test_get_server_certificate_timeout.<locals>.servername_cb  s    JJsOr    皙?)r}   rx  N)	r   r  r   r   rx  r   r  r  r   )r   r  s   & r   #test_get_server_certificate_timeout9SimpleBackgroundTests.test_get_server_certificate_timeout   s_    	33MBv~~..&&t'7'7*/2 ' 4 /...s   'A77B	c           
        \        \        P                  ! \        P                  4      \        P                  R R7      ;_uu_ 4       pVP                  V P                  4       RRR4       \        \        P                  ! \        P                  4      \        P                  RR7      ;_uu_ 4       pVP                  V P                  4       RRR4       V P                  \        P                  R4      ;_uu_ 4        \        P                  ! \        P                  4      ;_uu_ 4       p\        V\        P                  RR7      pVP                  V P                  4       RRR4       RRR4       R#   + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     LA; i  + '       g   i     R# ; i)rQ  )r|   r~   NrR  rS  rT  )	r   r   rY  r   r   r  r  r   r   )r   r   r   s   &  r   rV  "SimpleBackgroundTests.test_ciphers	  s$   fmmFNN;'*}}eE EHIIId&&'E fmmFNN;'*}}iI ILMIId&&'I ##CLL2MNNv~~..$$T.1mmEWY		$**+ / ONE E EI I
 /. ONNs<   E41F=-F.*8F	"F.4F	F	F+&F..F?	c                4   \         P                  \         P                  4      pVP                  \        R 7       V P                  VP                  4       . 4       VP                  \        P                  ! \        P                  4      RR7      ;_uu_ 4       pVP                  V P                  4       VP                  4       pV P                  V4       RRR4       V P                  \        VP                  4       4      ^4       R#   + '       g   i     L;; ir  r#   r  N)r   rT   rI   r   r  r   r+  r   r   rY  r  r  r  r  rK   r  s   &   r   test_get_ca_certs_capath.SimpleBackgroundTests.test_get_ca_certs_capath  s    nnS445!!!0))+R0__V]]6>>:-8  : :=>IId&&'==?DOOD!	:
 	S--/0!4: :s   =DD	c                   \         P                  \         P                  4      pVP                  \        R 7       \         P                  \         P                  4      pVP                  \        R 7       \
        P
                  ! \
        P                  4      pVP                  VRR7      ;_uu_ 4       pVP                  V P                  4       V P                  VP                  V4       V P                  VP                  P                  V4       W$n        V P                  VP                  V4       V P                  VP                  P                  V4       RRR4       R#   + '       g   i     R# ; ir  )r   rT   rI   r   r  r   rY  r   r  r  r   r   _sslobj)r   ctx1ctx2r   r^  s   &    r   test_context_setget)SimpleBackgroundTests.test_context_setget#  s    ~~c556""&"1~~c556""&"1MM&..)a==JJt''(MM"**d+MM"**,,d3JMM"**d+MM"**,,d3 >===s   2B&E""E3	c                   VP                  R \        P                  4      p^ p\        P                  ! V4       F  p	Rp
V^,          p V! V!  pVP                  4       pVP                  V4       V
f    MWV
\        P                  8X  g   KS  VP                  R4      pV'       d   VP                  V4       K  VP                  4        K  	  \        P                  '       d2   \        P                   P                  RWP"                  3,          4       X#   \        P
                   dH   pTP                  \        P                  \        P                  39  d   h TP                  p
 Rp?ELRp?ii ; i)rx  Ni   z"Needed %d calls to complete %s().
)r   r   SHORT_TIMEOUT
busy_retryr   r   r-  r{  SSL_ERROR_WANT_WRITEr1   sendallrf  ro   r  rm   rk   rn   r  )r   r   incomingoutgoingr_   r]   r   rx  r  r  r-  retrk  bufs   &&&&&*,       r   ssl_io_loop!SimpleBackgroundTests.ssl_io_loop2  s"    **Y(=(=>##G,AEQJE Dk --/CLL }#111ii&NN3'&&(/ -0 ???JJB %}}56 7
- <<  773#:#:#&#;#;#= =	 s   DE1*<E,,E1c                   \         P                   ! \         P                  4      pV P                  VP                  4       VP	                  V P
                  4       \        P                  4       p\        P                  4       p\        P                  \        P                  4      pV P                  VP                  4       V P                  VP                  \        P                  4       VP                  \         4       VP#                  W#R \$        4      pV P'                  VP(                  P*                  V4       V P-                  VP/                  4       4       V P-                  VP1                  4       4       V P-                  VP3                  4       4       V P5                  \6        VP8                  4       R\        P:                  9   d6   VP1                  4       R8w  d!   V P-                  VP=                  R4      4       V P?                  WW5P@                  4       V P                  VP/                  4       4       V P-                  VP3                  4       4       V PC                  VP1                  4       4       V P                  VP9                  4       4       R\        P:                  9   d6   VP1                  4       R8w  d!   V P                  VP=                  R4      4        V P?                  WW5PD                  4       V P5                  \        PH                  VPJ                  R4       R#   \        PF                   d     LDi ; i)Fr  TLSv1.3r  N)&r   rY  r  r  r  r  r   r   rT   rI   r  r   r   r   r   r   r   r]  r   r   r  ownerr  cipherrW   shared_ciphersr   r   r  rC  r  r  rz  assertIsNotNoner  SSLSyscallErrorr   ro   )r   r   r  r  r<   sslobjs   &     r   test_bio_handshake(SimpleBackgroundTests.test_bio_handshakeT  sA   }}V^^,

#T%%&==?==?nnS445**+#*;*;<!!*-h%68fnn**F3&--/*&..*+&//12*f&8&89 34449IY9Vf88FG3F3FG(&//12V^^-.**,-34449IY9VOOF66|DE	TX}}E
 	#,,f=	 "" 	 	s   'L0 0MMc                   \         P                   ! \         P                  4      pV P                  VP                  4       VP	                  V P
                  4       \        P                  4       p\        P                  4       p\        P                  \        P                  4      pR Vn
        \        P                  Vn        VP                  W#R 4      pV P                  WW5P                  4       RpV P                  WW5P                   V4       V P                  WW5P"                  R4      pV P%                  VR4       V P                  WW5P&                  4       R# )F   FOO
   s   foo
N)r   rY  r  r  r  r  r   r   rT   rI   r   r   r   r]  r  rz  ro   r1   r   r  )r   r   r  r  r<   r'  reqr  s   &       r   test_bio_read_write_data.SimpleBackgroundTests.test_bio_read_write_datax  s    }}V^^,

#T%%&==?==?nnS445"--h%83F3FG<<EtxdKh'==Ar    c                
   \        4       w  rp\        P                  ! \        P                  4      ;_uu_ 4       pVP                  V P                  4       \
        P                  4       p\
        P                  4       pVP                  WVVR 7      pV P                  WEWgP                  4       VP                  4        V P                  \
        P                  VP                  4       RRR4       R#   + '       g   i     R# ; i)r  N)r   r   rY  r  r  r   r   r]  r  rz  r  r   SSLEOFErrorr1   )r   r   r   r   r   r  r  r'  s   &       r   test_transport_eof(SimpleBackgroundTests.test_transport_eof  s    3B3D0]]6>>**dLL))*}}H}}H#,,X=E - GFTX7J7JK  coov{{; +***s   B-C11D	)r  r   N)!r  r>  r?  r@  __doc__r  r  r  r  r  r  r  r  r  r[   re  r   r   r  r  r  r  r  r  rV  r  r  r  r(  r.  r2  rF  rG  rH  s   @r   r  r    s     I/,< ))4"(=&"."* __RWW_&RS9 T9$d*O5*C
4,
54 D">HB"< <r    r  networkc                      a  ] tR tRt o R t]P                  ! ]P                  R4      ]	P                  ! R4      R 4       4       tRtV tR# )NetworkedTestsi  c                d   \         P                  ! \        4      ;_uu_ 4        \        \        P                  ! \        P
                  4      \        P                  R R7      pV P                  VP                  4       VP                  R4       VP                  \        R34      pV^ 8X  d   V P                  R4       M&V\        P                  8X  d   V P                  R4       V P                  V\        P                   \        P"                  34       RRR4       R#   + '       g   i     R# ; i)Fr  gHz>  z!REMOTE_HOST responded too quicklyzNetwork unreachable.N)r   transient_internetREMOTE_HOSTr   r   rY  r   r   r  r  rv  r+  r&  r-  ENETUNREACHr  EAGAINr1  r  s   &  r   test_timeout_connect_ex&NetworkedTests.test_timeout_connect_ex  s     --k:: v~~!>*-*;*;8=?A OOAGG$LL#{C01BQwABu(((45MM"u||U->->?@ ;:::s   C1DD/	z
Needs IPv6walltimec                    \         P                  ! R 4      ;_uu_ 4        \        V R R4       \        V R R4       RRR4       R#   + '       g   i     R# ; i)zipv6.google.comr9  N)r   r:  r  r  r   s   &r    test_get_server_certificate_ipv6/NetworkedTests.test_get_server_certificate_ipv6  s@     --.?@@(/@#F-d4EsK A@@@s   AA	r@   N)r  r>  r?  r@  r>  r[   rB  r   IPV6_ENABLEDr   requires_resourcerB  rF  rG  rH  s   @r   r7  r7    sH     A  33\Bz*L + CLr    r7  c           	      r   \         P                  W34      pV'       g   V P                  R V: RV: R24       \         P                  W3VR7      pV'       g   V P                  R V: RV: R24       \        P                  '       d/   \
        P                  P                  RV: RV: RV: R24       R# R# )r  r  r  r  r  r  r   N)r   r  r4  r   rm   rk   rn   ro   )testr  r3  r  r7  s   &&&& r   r  r    s{    

$
$d\
2C		tTBC

$
$d\D
$
AC		tTBC

dTWXY r    c                    \         P                  ! V 4      ;_uu_ 4         \        P                  W3\        R 7      pV P                  RV: RV: RV: R24       RRR4       R#   \        P                   dG   p\        P                  '       d'   \        P                  P                  RT,          4        Rp?L`Rp?ii ; i  + '       g   i     R# ; i)r  zGot server certificate z for r  r  z%s
N)r
   check_no_resource_warningr   r  r   r4  r   r   rm   rk   rn   ro   )rG  r  r3  r7  xs   &&&  r   r  r    s    		2	24	8	8	R,,d\H,MC IIT4PQ 
9	8 || 	-

  !,	- 
9	8	8s3   CA%C%C :<B;6C;C  CC	)make_https_serverc                   |   a  ] tR tRt o  ! R R]P
                  4      tRR ltR tR t	RR lt
R	 tR
 tR tRtV tR# )r:  i  c                   H   a  ] tR tRt o RtR tR tR tR tR t	R t
R	tV tR
# )$ThreadedEchoServer.ConnectionHandleri  zA mildly complicated class, because we want it to work both
with and without the SSL wrapper around the socket connection, so
that we can test the STARTTLS functionality.c                    Wn         R V n        W n        W0n        V P                  P	                  R4       RV n        \        P                  P                  V 4       RV n	        R# FTN)
r2  runningr   addrrx  sslconn	threadingr   __init__daemon)r   r2  connsockrR  s   &&&&r   rU  -ThreadedEchoServer.ConnectionHandler.__init__  sL     K DL IIII!!$'DL%%d+DKr    c                T    V P                   P                  P                  V P                  R R7      V n        V P                   P
                  P                  V P                  P                  4       4       V P                   P                  P                  V P                  P                  4       4       V P                   P                  P                  \        P                  8X  Ed+   V P                  P                  4       p\        P                  '       d^   V P                   P                  '       dB   \         P"                  P%                  R\&        P(                  ! V4      ,           R,           4       V P                  P                  R 4      p\        P                  '       dm   V P                   P                  '       dQ   Vf!   \         P"                  P%                  R4       M,\         P"                  P%                  R\+        V4       R24       V P                  P-                  4       p\        P                  '       dS   V P                   P                  '       d7   \         P"                  P%                  R\/        V4      ,           R,           4       R #   \0        \2        \4        3 d   pT P                   P6                  P                  \/        T4      4       T P                   P                  '       d-   \9        R	\;        T P<                  4      ,           R
,           4       RT n        T PA                  4         Rp?R# Rp?i\        PB                  \D        3 d   pT P                   P6                  P                  \/        T4      4       T P                   P                  '       d-   \9        R	\;        T P<                  4      ,           R
,           4       TPF                  \F        PH                  8w  d-   \         PJ                  R8w  d   RT n        T PA                  4         Rp?R# Rp?ii ; i)TrY  z client cert is r   Nz client did not provide a cert
z cert binary is zb
z" server: connection cipher is now z'
 server:  bad connection attempt from z:
Fdarwin)&r2  r   r   r   rS  selected_alpn_protocolsr  selected_alpn_protocolr$  r   r   r   r  r   rm   chattyrk   rn   ro   r   r   rK   r#  rD   ConnectionResetErrorBrokenPipeErrorConnectionAbortedErrorconn_errorsrr   r   rR  rQ  r  r   re  r-  
EPROTOTYPErD  )r   r  cert_binaryr#  rk  s   &    r   	wrap_conn.ThreadedEchoServer.ConnectionHandler.wrap_conn  s   :#{{22>>II4  ?  133::4<<;^;^;`aR **11$,,2M2M2OP;;&&22c6G6GG<<335D4;;+=+=+=

(();fnnT>R)RUY)YZ"&,,":":4"@K4;;+=+=+=&.JJ,,-OPJJ,,/?K@P?QQT-UV,,.???t{{'9'9'9JJ$$%ICPVK%WZ^%^_m )/;QR  ''..s1v6;;%%% !KdSWS\S\o!]`e!ef$

LL'*  ''..s1v6;;%%% !KdSWS\S\o!]`e!ef
 77e...3<<83K#(DLJJL+s,   A3J P'*BL==P'P'CP""P'c                    V P                   '       d   V P                   P                  4       # V P                  P                  R 4      # )r,  )rS  r1   r   rf  r   s   &r   r1   )ThreadedEchoServer.ConnectionHandler.read	  s1    |||||((**yy~~d++r    c                    V P                   '       d   V P                   P                  V4      # V P                  P                  V4      # r?   )rS  ro   r   rj  )r   r  s   &&r   ro   *ThreadedEchoServer.ConnectionHandler.write!	  s3    |||||))%00yy~~e,,r    c                    V P                   '       d   V P                   P                  4        R # V P                  P                  4        R # r?   )rS  r  r   r   s   &r   r  *ThreadedEchoServer.ConnectionHandler.close'	  s)    |||""$		!r    c                   R V n         V P                  P                  '       g   V P                  4       '       g   R# V P                   '       Ed    V P	                  4       pVP                  4       pV'       gA   RV n          V P                  P                  4       V n        RV n        V P                  4        K|  VR8X  dd   \        P                  '       d<   V P                  P                  '       d    \        P                  P!                  R4       V P                  4        R# V P                  P                  '       d   VR8X  d~   \        P                  '       d<   V P                  P                  '       d    \        P                  P!                  R4       V P!                  R4       V P                  4       '       g   R# EK  V P                  P                  '       d   V P                  '       d   VR8X  d   \        P                  '       d<   V P                  P                  '       d    \        P                  P!                  R	4       V P!                  R4       V P                  P                  4       V n        RV n        \        P                  '       dB   V P                  P                  '       d#   \        P                  P!                  R
4       EK  EK  EK  VR8X  d   \        P                  '       d<   V P                  P                  '       d    \        P                  P!                  R4       V P                  P#                  R4      pV P!                  \%        V4      P'                  R4      R,           4       EKC  VR8X  d   \        P                  '       d<   V P                  P                  '       d    \        P                  P!                  R4        V P                  P)                  4        V P!                  R4       EK  VR8X  dE   V P                  P/                  4       e   V P!                  R4       EK  V P!                  R4       EK  VR8X  dN   V P                  P/                  4       pV P!                  \%        V4      P'                  R4      R,           4       EKi  VR8X  dY   V P                  P0                  P3                  4       pV P!                  \5        V4      P7                  ^R4      R,           4       EK  VR8X  dY   V P                  P0                  P9                  4       pV P!                  \5        V4      P7                  ^R4      R,           4       EK'  \        P                  '       d{   V P                  P                  '       d_   V P                  ;'       d    R;'       g    Rp\        P                  P!                  RV: RV: RVP;                  4       : RV: R2	4       V P!                  VP;                  4       4       EK  R#   \         d     ELi ; i  \*        P,                   d=   pT P!                  \%        T4      P'                  R4      R,           4        Rp?EK9  Rp?ii ; i  \         Ed   p\=        T\>        4      '       dh   T P                  P@                  '       d/   \        P                  '       d   \C        RT PD                   24       T P                  4        RT n          Rp?R# T P                  P@                  '       d"   \        P                  '       d   \G        R 4        T P!                  R!4       M  \         d     Mi ; iT P                  4        RT n          Rp?EKI  Rp?ii ; i)"TNFs   overz" server: client closed connection
   STARTTLSz2 server: read STARTTLS from client, sending OK...
   OK
   ENDTLSz0 server: read ENDTLS from client, sending OK...
z* server: connection is now unencrypted...
s   CB tls-uniquez@ server: read CB tls-unique from client, sending our CB data...
r  us-ascii   
   PHAz( server: initiating post handshake auth
   HASCERT   TRUE
   FALSE
   GETCERTs   VERIFIEDCHAINbigs   UNVERIFIEDCHAIN	encryptedunencryptedz server: read z (z), sending back z)...
z Connection reset by peer: zTest server failure:
s   ERROR
)$rQ  r2  starttls_serverrd  r1   striprS  r  r   re  r  r   rm   connectionchattyrk   rn   ro   r  r   r  verify_client_post_handshaker   r   r  r  get_verified_chainrK   to_bytesget_unverified_chainr%  rC   ConnectionErrorr]  printrR  rr   )r   msgstrippedr   rk  r  certsctypes   &       r   run(ThreadedEchoServer.ConnectionHandler.run-	  s   DL;;...~~'',,,[)))+C"yy{H#',0(,(;(;(=DI ,0DL

!W,"???t{{/K/K/KJJ,,-RS

++555"k1"???t{{/K/K/KJJ,,-bc

7+#~~//"  0++555$,,,&)3"???t{{/K/K/KJJ,,-`a

7+$(LL$7$7$9	'+"???t{{/K/K/KJJ,,-Z[ 0L?!%55"???t{{/K/K/KJJ,,-pq#||??M

4:#4#4Z#@5#HI!V+"???t{{/K/K/KJJ,,-XY0 LLEEG !JJw/!Z/<<335A JJy1 JJz2!Z/#||779

4:#4#4Z#@5#HI!%55 $ 4 4 G G I

3u:#6#6q%#@5#HI!%77 $ 4 4 I I K

3u:#6#6q%#@5#HI#OOO KK888%)\\%A%Ak$S$SmEJJ,,03UCIIK.P Q

399;/Q   ' ! !	!N  #|| K JJtAw~~j'AE'IJJK2  )!!_55  ;;---'///!$?		{"KL

',{{)))gooo$%=>

:." JJL#(DLL')si  'Y= 8Y=  X Y= 8Y= Y= 1/Y= "Y= >Y= Y= 7AY= Y= Y= 0Y= Y= )A+Y= Y= 1Y= Y= 6Y= A*Y= ?Y= Y= 8Y= X) 2Y= 4Y= =Y= AY= %AY= AY= #Y= 9Y= Y= (	Y= 2A Y= X&"Y= %X&&Y= )Y:>0Y5.Y= 5Y::Y= =^
	1^;^/^^"^8^]^]$!^#]$$^^
)rR  rV  rQ  r2  r   rS  N)r  r>  r?  r@  r4  rU  rd  r1   ro   r  r  rF  rG  rH  s   @r   ConnectionHandlerrN    s0     	8	;	z	,	-	"a	) a	)r    r  Nc                $   V
'       d   Wn         M\        P                  Ve   TM\        P                  4      V n         Ve   TM\        P                  V P                   n        V'       d   V P                   P                  V4       V'       d   V P                   P                  V4       V'       d   V P                   P                  V4       V	'       d   V P                   P                  V	4       WPn
        W`n        Wpn        \        P                  ! 4       V n        \        P                   ! V P                  4      V n        R V n        RV n        . V n        . V n        . V n        \.        P0                  P3                  V 4       RV n        RV n        R # NFT)r   r   rT   rH   r   r   r   r   set_alpn_protocolsr:   r]  r|  rz  r   r   r   r*  r3  flagactiver[  r$  ra  rT  r   rU  rV  _in_context)r   certificatessl_versioncertreqscacertsr]  r|  rz  alpn_protocolsr~   r   s   &&&&&&&&&&&r   rU  ThreadedEchoServer.__init__	  s   
 "L>>-8-D +6/2/F/FHDL 5=4H-0]] LL$227;,,[9//?((1 0.MMO	!++DII6		')$ !!$' r    c                    V P                   '       d   \        R 4      hRV n         V P                  \        P                  ! 4       4       V P
                  P                  4        V # )z&Re-entering ThreadedEchoServer contextT)r  r   startrT  Eventr  waitr   s   &r   	__enter__ThreadedEchoServer.__enter__	  sH    EFF

9??$%		r    c                |    V P                   '       g   Q hR V n         V P                  4        V P                  4        R# FN)r  stopr   r   r]   s   &*r   __exit__ThreadedEchoServer.__exit__	  s.     				r    c                    V P                   '       g   \        R 4      hWn        \        P                  P                  V 4       R# )4ThreadedEchoServer must be used as a context managerN)r  r   r  rT  r   r  r   r  s   &&r   r  ThreadedEchoServer.start	  s9    FH H	t$r    c                   V P                   '       g   \        R 4      hV P                  P                  R4       V P                  P	                  ^4       RV n        V P                  '       d   V P                  P                  4        V P
                  '       d    V P                  P                  4       w  r\        P                  '       dI   V P                  '       d7   \        P                  P                  R\        V4      ,           R,           4       V P!                  WV4      pVP#                  4        VP%                  4        K  V P/                  4        R#   \&         dN   p\        P                  '       d,   \        P                  P                  RT: R24        Rp?EK   Rp?EK&  Rp?i\(         d    T P+                  4         EKH  \,         dy   p\        P                  '       dW   T P                  '       d>   \        P                  P                  R\        T4      ,           R,           4        Rp?EK   Rp?EK   Rp?EK  Rp?ii ; i)r  g      ?Tz server:  new connection from r   z connection timeout Nz connection handling failed: )r  r   r   rv  listenr  r  r  r  r   rm   r]  rk   rn   ro   r   r  r  r   TimeoutErrorKeyboardInterruptr  BaseExceptionr  )r   newconnconnaddrhandlerrk  s   &    r   r  ThreadedEchoServer.run	  s   FH H		S!		999IIMMOkkkJ$(II$4$4$6!???t{{{JJ$$%E'+H~&68<&= >00I 	

   E???JJ$$';A5%CDD #$ 		  J???t{{{JJ$$7$q'ADHJ J (3?JsD   AE A(E I%:F--I:III'I6IIc                h    V P                   e$   V P                   P                  4        R V n         R # R # r?   )r   r  r   s   &r   r  ThreadedEchoServer.close	  s&    99 IIOODI !r    c                    R V n         R# r  )r  r   s   &r   r  ThreadedEchoServer.stop	  s	    r    )r  r  r]  ra  r|  r   rV  r  r3  r[  r$  r   rz  )
NNNNTFFNNNr?   )r  r>  r?  r@  rT  r   r  rU  r  r  r  r  r  r  rF  rG  rH  s   @r   r:  r:    sC     @)I,, @)D!!F%>
 r    r:  c                   x   a  ] tR tRt o  ! R R]P
                  4      tR tR tR t	R t
RR	 ltR
 tR tRtV tR# )AsyncoreEchoServeri	  c                   \   a  ] tR tRt o  ! R R]P
                  4      tR tR tR t	Rt
V tR# )	AsyncoreEchoServer.EchoServeri	  c                   D   a  ] tR tRt o R tR tR tR tR tR t	Rt
V tR	# )
/AsyncoreEchoServer.EchoServer.ConnectionHandleri	  c                    \        VR VRR7      V n        \        P                  P	                  W P                  4       R V n        V P                  4        R# )TF)r   r   r  N)r   r   r   dispatcher_with_sendrU  _ssl_accepting_do_ssl_handshake)r   connr   s   &&&r   rU  8AsyncoreEchoServer.EchoServer.ConnectionHandler.__init__	  sG    .t7?FKM --66t[[I&*#&&(r    c                    \        V P                  \        P                  4      '       d2   V P                  P	                  4       ^ 8  d   V P                  4        K1  R# )r   T)rC   r   r   r   r  handle_read_eventr   s   &r   readable8AsyncoreEchoServer.EchoServer.ConnectionHandler.readable	  s;    dkk3==99++--/!3..0r    c                    V P                   P                  4        R V n        R#   \        P                  \        P
                  3 d     R# \        P                   d    T P                  4       u # \        P                   d    h \         dG   pTP                  ^ ,          \        P                  8X  d   T P                  4       u Rp?#  Rp?R# Rp?ii ; ir  )r   rz  r  r   ry  r  r1  handle_closer   re  r]   r-  ECONNABORTEDr   errs   & r   r  AAsyncoreEchoServer.EchoServer.ConnectionHandler._do_ssl_handshake
  s    0KK,,. +0D' ,,c.C.CD  /,,..||  3xx{e&8&88#0022 93s9   % %CC C3C
CC5CCCc                l   V P                   '       d   V P                  4        R# V P                  R 4      p\        P                  '       d0   \
        P                  P                  R\        V4      ,          4       V'       g   V P                  4        R# V P                  VP                  4       4       R# )r,  z server:  read %s from client
N)r  r  rf  r   rm   rk   rn   ro   r   r  rj  r%  )r   r   s   & r   handle_read;AsyncoreEchoServer.EchoServer.ConnectionHandler.handle_read
  sk    &&&**,99T?D

(()JTRVZ)WX

		$**,/r    c                    V P                  4        \        P                  '       d3   \        P                  P                  R V P                  ,          4       R# R# )z server:  closed connection %s
N)r  r   rm   rk   rn   ro   r   r   s   &r   r  <AsyncoreEchoServer.EchoServer.ConnectionHandler.handle_close 
  s5    

???JJ$$%G$++%UV #r    c                    h r?   r@   r   s   &r   rr   <AsyncoreEchoServer.EchoServer.ConnectionHandler.handle_error%
  s    r    )r  r   N)r  r>  r?  r@  rU  r  r  r  r  rr   rF  rG  rH  s   @r   r  r  	  s)     )0
0W
 r    r  c                   Wn         \        P                  ! \        P                  \        P                  4      p\        P
                  ! VR 4      V n        \        P                  P                  W4       V P                  ^4       R# rW  )r   r   rY  SOCK_STREAMr   r*  r3  r   
dispatcherrU  r  r  s   && r   rU  &AsyncoreEchoServer.EchoServer.__init__(
  sT    $M==1C1CDD%//b9DI((4KKNr    c                    \         P                  '       d'   \        P                  P	                  R V,          4       V P                  WP                  4       R# )z$ server:  new connection from %s:%s
N)r   rm   rk   rn   ro   r  r   )r   sock_objrR  s   &&&r   handle_accepted-AsyncoreEchoServer.EchoServer.handle_accepted/
  s5    

  !H$!NO""8]];r    c                    h r?   r@   r   s   &r   rr   *AsyncoreEchoServer.EchoServer.handle_error4
  s    r    )r   r3  N)r  r>  r?  r@  r   r  r  rU  r  rr   rF  rG  rH  s   @r   
EchoServerr  	  s,     1	 = = 1	f		<
	 	r    r  c                    R V n         RV n        V P                  V4      V n        V P                  P                  V n        \
        P                  P                  V 4       RV n        R # r  )	r  r  r  r2  r3  rT  r   rU  rV  )r   r   s   &&r   rU  AsyncoreEchoServer.__init__7
  sL    	ooh/KK$$	!!$'r    c                T    R V P                   P                  : RV P                  : R2# )<rh   >)r  r  r2  r   s   &r   __str__AsyncoreEchoServer.__str__?
  s     NN33T[[AAr    c                    V P                  \        P                  ! 4       4       V P                  P	                  4        V # r?   )r  rT  r  r  r  r   s   &r   r  AsyncoreEchoServer.__enter__B
  s(    

9??$%		r    c                   \         P                  '       d    \        P                  P	                  R 4       V P                  4        \         P                  '       d    \        P                  P	                  R4       V P                  4        \         P                  '       d    \        P                  P	                  R4       \        P                  ! RR7       R# )z cleanup: stopping server.
z! cleanup: joining server thread.
z cleanup: successfully joined.
T)
ignore_allN)	r   rm   rk   rn   ro   r  r   r   	close_allr  s   &*r   r  AsyncoreEchoServer.__exit__G
  sv    ???JJ;<		???JJAB		???JJ?@d+r    Nc                P    Wn         \        P                  P                  V 4       R # r?   )r  rT  r   r  r  s   &&r   r  AsyncoreEchoServer.startS
  s    	t$r    c                    R V n         V P                  '       d   V P                  P                  4        V P                   '       d    \        P                  ! ^4       K+  R#     K2  ; ir   )r  r  r  r   loopr   s   &r   r  AsyncoreEchoServer.runW
  sH    999IIMMOkkka  s   A! !A&c                H    R V n         V P                  P                  4        R# r  )r  r2  r  r   s   &r   r  AsyncoreEchoServer.stopa
  s    r    )r  rV  r  r3  r2  r?   )r  r>  r?  r@  r   r  r  rU  r  r  r  r  r  r  rF  rG  rH  s   @r   r  r  	  sC     Bh)) BHB

,% r    r  c                t   / p\        VVRR7      pT;_uu_ 4        V P                  \        P                  ! 4       WVR7      ;_uu_ 4       p	V	P                  \        VP
                  34       V\        V4      \        V4      3 EF  p
V'       d=   \        P                  '       d'   \        P                  P                  RV,          4       V	P                  V
4       V	P                  4       pV'       d=   \        P                  '       d'   \        P                  P                  RV,          4       WP                  4       8w  g   K  \        RVR,          \!        V4      VR,          P                  4       \!        V4      3,          4      h	  V	P                  R4       V'       d6   \        P                  '       d    \        P                  P                  R	4       VP#                  R
V	P%                  4       RV	P'                  4       RV	P)                  4       RV	P+                  4       RV	P-                  4       RV	P.                  RV	P0                  /4       V	P3                  4        RRR4       VP4                  VR&   VP6                  VR&   RRR4       V#   + '       g   i     L8; i  + '       g   i     T# ; i)zK
Launch a server, connect a client to it and try various reads
and writes.
Fr   r]  r|  )r   session client:  sending %r...
 client:  read %r
4bad data <<%r>> (%d) received; expected <<%r>> (%d)
N   N   over
 client:  closing connection.
compressionr#  peercertclient_alpn_protocolrW   session_reusedr  Nserver_alpn_protocolsserver_shared_ciphers)r:  r   r   r  r,  r3  r   r  r   rm   rk   rn   ro   r1   r%  AssertionErrorrK   r  r  r#  r  r\  rW   r  r  r  r[  r$  )r   r   indatar]  r|  sni_namer  r7  r2  r   argoutdatas   &&&&&&&     r   server_params_testr  e
  s    E'-168F 
'' ( ( ; ;>?IItV[[)*	& 1:f3EF#

((7&@B&&(#

(()>)HIlln,(O"3<W!#;,,.F==> > G GGI???JJ$$%FGLLq}}!((*AMMO&(@(@(B199; !"2"2199  GGI?;@ *0)G)G%&)/)>)>%&E 
F LE; ; 
F LsK   /J&
AJ	%AJ	4J	
7J	AJ	%J	;B(J	#&J&J#J&&J7	c                   Vf   \         P                  p\         P                  R\         P                  R\         P                  R/V,          p\        P
                  '       df   T;'       d    R;'       g    Rp\        P                  P                  V\         P                  V4      \         P                  V 4      V3,          4       \        P                  ! 4       ;_uu_ 4        \         P                  V4      pV;P                  V,          un        \         P                  V 4      p	V	;P                  V,          un        RRR4       \        P                  VR4      p
V
ee   \!        X	R4      '       dS   V \         P"                  8X  d>   V	P$                  V
8  d-   \        P                  ! 4       ;_uu_ 4        Wn        RRR4       XP&                  \         P"                  8X  d   VP)                  R4       \+        X	V4       W3 F3  pW;n        VP/                  \0        4       VP3                  \4        4       K5  	   \7        WR	R	R
7      pV'       g;   \9        R\         P                  V4      : R\         P                  V 4      : R24      hVRJd*   W,R,          8w  d   \9        RV: RVR,          : 24      hR# R#   + '       g   i     EL; i  + '       g   i     EL; i  \         P:                   d    T'       d   h  R# \<         d4   pT'       g    TP>                  \>        P@                  8w  d   h  Rp?R# Rp?ii ; i)a$  
Try to SSL-connect using *client_protocol* to *server_protocol*.
If *expect_success* is true, assert that the connection succeeds,
if it's false, assert that the connection fails.
Also, if *expect_success* is a string, assert that it is the protocol
version actually used by the connection.
Nr   r   r   z %s->%s %s
z {%s->%s} %s
r6   rQ  F)r]  r|  zClient protocol z  succeeded with server protocol r  TrW   zversion mismatch: expected z, got )!r   r   r   r   r   rm   rk   rn   ro   get_protocol_namer
   r\  rT   r  PROTOCOL_TO_TLS_VERSIONr   r7   rG   r6   rL   r:   r=   r   r   r   r   r   r  r  r   re  r-  
ECONNRESET)server_protocolclient_protocolexpect_success	certsreqsserver_optionsclient_optionscerttype	formatstrr   r   min_versionr<   r7  rk  s   &&&&&&        r   try_protocol_combor  
  s    MM	{?? 	H
 #66KK;K	

//@//@"$$ 	%
 
	'	'	)	)8.08.0 
* *--otDK N$566s///**[8 ++---8* . #"2"22""5)7/#O,!!*- 0G">*/%I  ((9((9;< < D( )$44 $2E)4D"F G G 5 )c 
*	)	)" .--( <<   QWW(8(88 9sC   &AK:K K) K	K&	)MM
MM(MMc                 p    V P                  4        F!  pV F  pR V 2VR,          9   g   K    R# 	  K#  	  R# )zKx=descriptionTF)r^  )r<   aliasesr#  aliass   &&  r   supports_kx_aliasr  
  s8    //#EUG}} 55  $ r    c                     a  ] tR tRt o ]P
                  ! R4      R 4       t]P                  ! ]P                  R4      R 4       t
R tR tR t]P                  ! ]P                  R	4      R
 4       tR t]P                  ! ]R4      R 4       tR tRPR ltR t]! R4      R 4       tR tR tR t]! R4      R 4       t]! R4      R 4       t]! R4      R 4       t]! R4      R 4       tR t R t!R  t"R! t#R" t$R# t%R$ t&R% t'R& t(R' t)R( t*R) t+R* t,]! R4      R+ 4       t-]! R4      ]! R4      ].R, 4       4       4       t/]! R4      ].R- 4       4       t0]! R4      ]! R4      ].R. 4       4       4       t1]! R4      R/ 4       t2R0 t3]P                  ! R1]Ph                  9   R24      R3 4       t5R4 t6]P                  ! ]7! ]R54      R64      R7 4       t8R8 t9R9 t:R: t;R; t<R< t=R= t>R> t?R? t@R@ tARA tBRB tCRC tDRD tERE tFRF tGRG tHRH tIRI tJRJ tK]! R4      ]P                  ! ]P                  RK4      RL 4       4       tM]! R4      ]P                  ! ]P                  RK4      RM 4       4       tNRNtOV tPRO# )QThreadedTestsi
  r@  c                (   \         P                  '       d    \        P                  P	                  R4       \        4       w  rpV P                  \        P                  \        P                  R7      ;_uu_ 4        \        VVRRVR7       RRR4       RVn        V P                  \        P                  \        P                  R7      ;_uu_ 4        V P                  \        P                  4      ;_uu_ 4       p\        VVRRVR7       RRR4       V P                  R\        XP                   4      4       RRR4       V P                  \        P                  \        P                  R7      ;_uu_ 4        V P                  \        P                  4      ;_uu_ 4       p\        VVRRR7       RRR4       V P                  R\        XP                   4      4       RRR4       V P                  \        P                  \        P                  R7      ;_uu_ 4        V P                  \        P                  4      ;_uu_ 4       p\        VVRRR7       RRR4       V P                  R\        XP                   4      4       RRR4       R#   + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL ; i  + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     R# ; i)	z2Basic test of an SSL client connecting to a serverr   )r  r2  T)r   r   r]  r|  r  NFz@Cannot create a client socket with a PROTOCOL_TLS_SERVER context)r   r   r]  r|  )r   rm   rk   rn   ro   r   r   r   rI   rH   r  r   r   r   r  rD   rl   )r   r   r   r   rk  s   &    r   	test_echoThreadedTests.test_echo
  s!    ???JJT"3B3D0\\!8!8AXAX\YYn.<&*T(02 Z ).%\\!8!8AXAX\YY""3<<00A".2@*.,46 1
 MMRAKK  Z \\!8!8AXAX\YY""3<<00A".2@*.G 1 MMRAKK  Z \\!8!8AXAX\YY""3<<00A".2@*.G 1 MMRAKK " ZY9 ZYY 100 ZYY 100 ZYY 10 ZYYsx   :J	(J19J	
-J16(KK	.-K(L K-	-L 	J	J.(	J11K	K	KK*	-K=8L  L	z*test is only useful if the GIL is disabledc           
     2   . p\         P                  P                  pR s V P                  V P
                  V P                  V P                  \        P                  ! V P                  VR7      V P                  V P                  3 FS  p\        ^4       FA  pV P                  W4R7      ;_uu_ 4        VP                  \!        VR7      4       RRR4       KC  	  KU  	  \"        P$                  ! 4       ;_uu_ 4       pV F6  pV P                  VR7      ;_uu_ 4        VP'                  4        RRR4       K8  	  V F6  pV P                  VR7      ;_uu_ 4        VP)                  4        RRR4       K8  	  VP*                  e7   \-        VP*                  \.        P0                  4      '       g   VP*                  hRRR4       RsR#   + '       g   i     EKA  ; i  + '       g   i     K  ; i  + '       g   i     K  ; i  + '       g   i     LQ; i  Rsi ; i)T)warnings_filters)r_   numtargetN)threadF)rk   flagscontext_aware_warningsr   r  test_alpn_protocolstest_getpeercerttest_crl_checkrb   partialtest_check_hostname_idntest_wrong_cert_tls12test_wrong_cert_tls13r  r   r  r   r	   catch_threading_exceptionr  r   	exc_valuerC   r[   r\   )r   threadsr  r_   r  r  r"  s   &      r   test_ssl_in_multiple_threads*ThreadedTests.test_ssl_in_multiple_threads  s    99;; $ 	*((%%##!!00%5 **** !8C499vT':; :9 $$ ";;==%FV44 54 & &FV44 54 & <<+%bllH4E4EFF ll* > %*!! :99
 544 544 >= %*!sm   BH 0G	-H 9 G?G*+G?G+&AG?6H G
H G("	G?+G<6	G??H	
H Hc                l   \         P                  '       d    \        P                  P	                  R 4       \        4       w  rp\        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       RVR7      ;_uu_ 4       pVP                  \        VP                  34       V P                  \        4      ;_uu_ 4        VP                  4        RRR4       VP                  4        VP                  4       pV P!                  VR4       VP#                  4       p\         P                  '       dq   \        P                  P	                  \$        P&                  ! V4      R ,           4       \        P                  P	                  R\)        V4      ,           R,           4       RV9  d-   V P+                  R	\$        P&                  ! V4      ,          4       RVR,          9  d   V P+                  R
4       V P-                  RV4       V P-                  RV4       \.        P1                  VR,          4      p\.        P1                  VR,          4      p	V P3                  W4       RRR4       RRR4       R#   + '       g   i     EL; i  + '       g   i     L.; i  + '       g   i     R# ; i)r   Fr   r]  )r  r   NCan't get peer certificate.zConnection cipher is z.
r  z$No subject field in certificate: %s.zkMissing or invalid 'organizationName' field in certificate subject; should be 'Python Software Foundation'.r   r   r  )r   rm   rk   rn   ro   r   r:  r   r   r  r,  r3  r   r   r  rz  r  r#  r   r   rD   r4  r  r   r  rG  )
r   r   r   r   r2  r   r  r#  beforeafters
   &         r   r&  ThreadedTests.test_getpeercertD  s   ???JJT"3B3D0#N5IV++FMMODI<D , F FIJ		4-. &&z22MMO 3 }}&CD???JJ$$V^^D%9D%@AJJ$$%<s6{%JU%RSD(IID$nnT23 4I	?+IIBC k40j$/11${2CD00j1AB.7F V 322F F VVsD   0J"
?J		I;AJ	:D/J	)J";J	J	JJ""J3	c                   \         P                  '       d    \        P                  P	                  R 4       \        4       w  rp\        \        R^ 4      pV P                  VP                  \        P                  V,          4       \        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                   34       VP#                  4       pV P%                  VR4       RRR4       RRR4       V;P                  \        P&                  ,          un	        \        VRR7      p\(        P*                  ! R\(        P,                  4      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pV P/                  \        P0                  V4      ;_uu_ 4        VP                  \        VP                   34       RRR4       RRR4       RRR4       VP3                  \4        4       \        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                   34       VP#                  4       pV P%                  VR4       RRR4       RRR4       R#   + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     L}; i  + '       g   i     R# ; i)r   r  Tr2  r  r3  Nr  )r   rm   rk   rn   ro   r   rF   r   r   r  r  r:  r   r   r  r,  r3  r  r  r  r  r  r  r   r   r   CRLFILE)	r   r   r   r   r  r2  r   r  r  s	   &        r   r'  ThreadedTests.test_crl_checkh  s\   ???JJT"3B3D0S5q944c6H6H26MN $N4HV++FMMO<D , F FIJ		4-.}}&CD	F  	##s'@'@@##N4H

  dd	
 V++FMMO<D , F FIJ++CLL%@@IItV[[12 AF  	,,W5#N4HV++FMMO<D , F FIJ		4-.}}&CD	F V5F F F VV( A@F F F VVF F VVs   /KAK	K/L1)L 	"K-<L 	L /L;/AL(	3L;K	KK*	-K=8L 	 L	LL%	(L83L;;M	c                   \         P                  '       d    \        P                  P	                  R 4       \        4       w  rp\        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       VP                  4       pV P                  VR4       RRR4       RRR4       \        VRR7      p\        P                  ! R\        P                   4      pT;_uu_ 4        VP                  \        P                  ! 4       RR7      ;_uu_ 4       pV P#                  \$        P&                  V4      ;_uu_ 4        VP                  \        VP                  34       RRR4       RRR4       RRR4       \        VRR7      pT;_uu_ 4        \        P                  ! 4       ;_uu_ 4       pV P#                  \(        R4      ;_uu_ 4        VP                  V4       RRR4       RRR4       RRR4       R#   + '       g   i     ELg; i  + '       g   i     ELs; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)	r   Tr2  r  r3  Nr  invalidz'check_hostname requires server_hostname)r   rm   rk   rn   ro   r   r:  r   r   r  r,  r3  r  r  r  r  r  r   r   CertificateErrorr   )r   r   r   r   r2  r   r  r  s   &       r   rK  !ThreadedTests.test_check_hostname  s   ???JJT"3B3D0 $N4HV++FMMO<D , F FIJ		4-.}}&CD	F  $N4H

  dd	
 V++FMMO<E , G GJK++C,@,@%HHIItV[[12 IG  $N4HVA++J,UW W"..q1W ! V-F F F VV$ IHG G VW W ! VVs   /H?	AH+	H?/I9)I&	1"II&	I9J2 J	?JJ	J2+H<6	H??I	I#I&	&I61I99J		JJ	J/*J22K	z)test requires hostname_checks_common_namec                   \        4       w  rpVP                  '       g   Q hR Vn        \        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       RRR4       RRR4       \        \        4      w  rpR Vn        \        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pV P                  \        P                  4      ;_uu_ 4        VP                  \        VP                  34       RRR4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     LH; i  + '       g   i     LS; i  + '       g   i     R# ; i)FTr2  r  N)r   r  r:  r   r   r  r,  r3  r   r   r   SSLCertVerificationErrorr;  s   &     r   r  .ThreadedTests.test_hostname_checks_common_name  sO    4C3D0999995:2 $N4HV++FMMO<D , F FIJ		4-.F 
 4C93M05:2#N4HV++FMMO<D , F FIJ&&s'C'CDDIItV[[12 EF VF F V EDF F VVs`    /E7/"E$	E7/F0 (F	("F

F	F0$E4/E77F	
FF	F-(F00G	c           	        \         P                  \         P                  4      pVP                  \        4       VP                  R 4       \        p\         P                  \         P                  4      pVP                  \        4       \        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       VP!                  4       pV P#                  VR4       VP%                  4       ^ ,          P'                  R4      pV P#                  VR,          R4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i	zECDHE:ECDSA:!NULL:!aRSATr2  r  r3  -:Nr  NN)ECDHEECDSA)r   rT   rI   r   r   r:   SIGNED_CERTFILE_ECC_HOSTNAMErH   r   SIGNED_CERTFILE_ECCr:  r   r   r  r,  r3  r  r  r#  splitr   r   r   r   r2  r   r  r#  s   &       r   test_ecc_certThreadedTests.test_ecc_cert  s   (?(?@,,Z8""#<=/(?(?@&&':; $N4HV++FMMO<D , F FIJ		4-.}}&CDA,,S1r
,>?F VF F VVs%   /E6BE#	E6#E3.E66F	z2test requires RFC 5280 check added in OpenSSL 3.0+c                4   \         P                  4       pVP                  \        4       \        p\         P                  \
        P                  R 7      pVP                  \        4       \        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pV P                  \         P                  4      ;_uu_ 4        VP                  \        VP                   34       RRR4       RRR4       RRR4       \         P                  4       pVP                  \        4       V;P"                  \         P$                  ( ,          un        \         P                  \
        P                  R 7      pVP                  \        4       \        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                   34       VP'                  4       pV P)                  VR4       RRR4       RRR4       R#   + '       g   i     ELG; i  + '       g   i     ELS; i  + '       g   i     EL_; i  + '       g   i     LV; i  + '       g   i     R# ; i)rE  Tr2  r  Nr3  )r   r@  r   LEAF_MISSING_AKI_CA"LEAF_MISSING_AKI_CERTFILE_HOSTNAMEr   r  r   LEAF_MISSING_AKI_CERTFILEr:  r   r   r   r   r  r,  r3  r  r  r  r  )r   r   r   r   r2  r   r  s   &      r   test_verify_strict ThreadedTests.test_verify_strict  s    335,,-@A533G<O<O3P&&'@A#N4HV++FMMO<D , F FIJ&&s||44IItV[[12 5F  335,,-@A##(>(>'>>#33G<O<O3P&&'@A#N4HV++FMMO<D , F FIJ		4-.}}&CD	F V 544F F F VVF F VVsa    /I/(I	"H79I	I2/J!AI3	%J7I	I	I	II0	3J>JJ	c           	     |   \         P                  \         P                  4      pVP                  \        4       \         P
                  P                  Vn        VP                  R 4       \        p\         P                  \         P                  4      pVP                  \        4       VP                  \        4       \        VRR7      pT;_uu_ 4        VP                  \         P                   ! 4       VR7      ;_uu_ 4       pVP#                  \$        VP&                  34       VP)                  4       pV P+                  VR4       VP-                  4       ^ ,          P/                  R4      pV P+                  VR,          R4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; irB  )r   rT   rI   r   r   r   rS   rP   r:   rF  rH   r   rG  r   r:  r   r   r  r,  r3  r  r  r#  rH  rI  s   &       r   test_dual_rsa_eccThreadedTests.test_dual_rsa_ecc  s8   (?(?@,,Z8 *-)?)?&""#<=/(?(?@&&':;&&7 $N4HV++FMMO<D , F FIJ		4-.}}&CDA,,S1r
,>?F VF F VVs%   /F*BF	F*F'"F**F;	c                   \         P                  '       d    \        P                  P	                  R 4       \
        P                  \
        P                  4      pVP                  \        4       \
        P                  \
        P                  4      p\
        P                  Vn        RVn        VP                  \        4       . R	OpV F  w  rV\!        VRR7      pT;_uu_ 4        VP#                  \$        P$                  ! 4       VR7      ;_uu_ 4       pV P'                  VP(                  V4       VP+                  \,        VP.                  34       VP1                  4       p	V P'                  VP(                  V4       V P3                  V	R4       RRR4       RRR4       K  	  \!        VRR7      pT;_uu_ 4        VP#                  \$        P$                  ! 4       RR7      ;_uu_ 4       pV P5                  \
        P6                  4      ;_uu_ 4        VP+                  \,        VP.                  34       RRR4       RRR4       RRR4       \!        VRR7      ;_uu_ 4       pV'       d   \8        P:                  ! V 4      M	\=        4       ;_uu_ 4        V P5                  \>        4      ;_uu_ 4        VP#                  \$        P$                  ! 4       RR7       RRR4       RRR4       RRR4       \!        VRR7      ;_uu_ 4       pV'       d   \8        P:                  ! V 4      M	\=        4       ;_uu_ 4        V P5                  \@        4      ;_uu_ 4        VP#                  \$        P$                  ! 4       RR7       RRR4       RRR4       RRR4       R#   + '       g   i     EL; i  + '       g   i     EK  ; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL+; i  + '       g   i     EL7; i  + '       g   i     ELC; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)
r   Tr2  r  r3  Nzpython.example.orgz.pythontest.nets   knig.idn.pythontest.net))u   könig.idn.pythontest.netxn--knig-5qa.idn.pythontest.net)rV  rV  )s   xn--knig-5qa.idn.pythontest.netrV  )u(   königsgäßchen.idna2003.pythontest.net.xn--knigsgsschen-lcb0w.idna2003.pythontest.net)rW  rW  )s.   xn--knigsgsschen-lcb0w.idna2003.pythontest.netrW  ).xn--knigsgchen-b4a3dun.idna2008.pythontest.netrX  )s.   xn--knigsgchen-b4a3dun.idna2008.pythontest.netrX  )!r   rm   rk   rn   ro   r   rT   rH   r   IDNSANSFILErI   r   r   r   r   r   r:  r   r   r   r   r  r,  r3  r  r  r   r<  r
   rI  r   UnicodeErrorUnicodeDecodeError)
r   r  r   r   idn_hostnamesr   expected_hostnamer2  r   r  s
   &&        r   r)  %ThreadedTests.test_check_hostname_idn!  s&   ???JJT"(?(?@&&{3..!8!89!//!%%%j1
. 3@.O'tLF((9H ) J JMN$$Q%6%68IJIItV[[12==?D$$Q%6%68IJOOD*GHJ  3@ $N4HV$$V]]_5I % K KNO&&s';';<<IItV[[12 =K  ~dCCv $  99$? ]# # l++ARS ,	# D ~dCCv $  99$? ]# # 011 >    2	# DC7J J J  =<<K K K VV ,++	# # # DCC" 21	# # DCCs   $/N'A<NN':/O$)(O	"N<3O	;O$ 1P P	/'O8P	P 1Q4Q	'P49Q	QN$	N''N9<O	O	O!	O$$O5	8P		P	P	P  P1	4Q?Q	QQQ+	c           	        \        4       w  rpVP                  \        4       \        P                  Vn        \        P                  P                  Vn        \        VRRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       p VP                  \        VP                  34       V P                  R4       RRR4       RRR4       R#   \        P                    dG   p\"        P$                  '       d'   \&        P(                  P+                  RT,          4        Rp?LhRp?i\,         dg   pTP.                  \.        P0                  8w  d   h \"        P$                  '       d'   \&        P(                  P+                  RT,          4        Rp?LRp?ii ; i  + '       g   i     L; i  + '       g   i     R# ; i)zConnecting when the server rejects the client's certificate

Launch a server with CERT_REQUIRED, and check that trying to
connect to it with a wrong client certificate fails.
Tr  r  z'Use of invalid cert should have failed!z
SSLError is %r
Nz
socket.error is %r
)r   r   r   r   r   r   r   rS   rP   r:  r   r   r  r,  r3  r4  r   r   rm   rk   rn   ro   re  r-  r  r   r   r   r   r2  r   rk  s   &      r   r*  #ThreadedTests.test_wrong_cert_tls12q  sJ    4C3D0&&x0%(%6%6"),)?)?&#"4$
 V**6==?;C + E EHIE 		4-. 		CD!E V << ????JJ$$%9A%=> C77e...???JJ$$%=%AB	CE E VVsl   //GF1	 !C$F1	G$F.9<D:5F1	:F.F.5F)>&F)$F1	)F..F1	1G<GG	r  c                .   \        4       w  rpVP                  \        4       \        P                  Vn        \        P                  P                  Vn        \        P                  P                  Vn        \        VR R R7      pT;_uu_ 4        VP                  \        P                  ! 4       VRR7      ;_uu_ 4       pVP                  \        VP                  34       V P                  \         R4      ;_uu_ 4        VP#                  R4       VP%                  R4       VP#                  R4       VP%                  R4       RRR4       RRR4       RRR4       R#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R# ; i)	Tr  Fr   suppress_ragged_eofszsalert unknown ca|EOF occurred|TLSV1_ALERT_UNKNOWN_CA|closed by the remote host|Connection reset by peer|Broken pipe   datar  s   should have failed alreadyN)r   r   r   r   r   r   r   r  r6   r:  r   r   r  r,  r3  r   re  ro   r1   r;  s   &     r   r+  #ThreadedTests.test_wrong_cert_tls13  s'   3B3D0&&x0%(%6%6"),)?)?&),)?)?&#"4$
 V''8@=B ( D DGHIItV[[)*''   t56t	D V
 	D D VVs>   0F>A E0	>AEE0	FE-(E0	0F ;FF	c                  a aaaa \         P                  ! 4       o\         P                  ! 4       o\        P                  ! 4       o\        P                  ! S\
        4      oVVV3R lpVVVV 3R lp\         P                  ! VR7      pVP                  4         V! 4        VP                  4        R#   TP                  4        i ; i)zdA brutal shutdown of an SSL server should raise an OSError
in the client when attempting handshake.
c                     < SP                  4        SP                  4        SP                  4       w  rV P                  4        SP                  4        SP                  4        R # r?   )r  r  r  r  )newsockrR  listener_gonelistener_readyr   s     r   listener2ThreadedTests.test_rude_shutdown.<locals>.listener  sC    HHJ HHJMGMMOGGIr    c                  F  < SP                  4        \        P                  ! 4       ;_uu_ 4       p V P                  \        S34       SP                  4         \	        V 4      pSP                  R 4       RRR4       R#   \         d     Li ; i  + '       g   i     R# ; i)z2connecting to closed SSL socket should have failedN)r  r   r  r,  r   r4  re  )r  r  rj  rk  r3  r   s     r   	connector3ThreadedTests.test_rude_shutdown.<locals>.connector  s|    !A		4,'""$T/2H IIRS !
   !s/   (BA>#B>B	BBBB 	r   N)	rT  r  r   r   r*  r,  r   r  r   )r   rl  ro  rL  rj  rk  r3  r   s   f   @@@@r   test_rude_shutdown ThreadedTests.test_rude_shutdown  s     #*!)MMO&&q$/	 
	T 
	T H-			KFFHAFFHs   B2 2Cc           
     J   \         P                  '       d    \        P                  P	                  R 4       \
        P                  \
        P                  4      pVP                  \        4       \
        P                  \
        P                  4      p\        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       \        R7      ;_uu_ 4       p VP                  \         VP"                  34       V P%                  R4       R	R	R	4       R	R	R	4       R	#   \
        P&                   d   pRpT P)                  T\
        P*                  4       T P-                  TP.                  ^4       T P-                  TP0                  T4       RT R2pT P3                  \5        T4      T4       \6        P8                  ! R\6        P:                  4      pT P3                  \5        T4      T4        R	p?LR	p?ii ; i  + '       g   i     L; i  + '       g   i     R	# ; i)
r   Tr2  r  zExpected connection failurez&unable to get local issuer certificate(z|CERTIFICATE_VERIFY_FAILED)z(
                        certificate verify failed   # OpenSSL
                        |
                        CERTIFICATE_VERIFY_FAILED   # AWS-LC
                    )N)r   rm   rk   rn   ro   r   rT   rH   r   r   rI   r:  r   r   r   r  r,  r3  r4  r   rD  r?  r   verify_codeverify_messagerr  r   r  r  r  )r   r   r   r2  r   rk  r  r  s   &       r   test_ssl_cert_verify_error(ThreadedTests.test_ssl_cert_verify_error  s   ???JJT"(?(?@&&7..!8!89#N4HV$$V]]_5M % O ORS5IItV[[12II;<	O V || 5BC))!S-I-IJ$$Q]]B7$$Q%5%5s;u$?@E$$T!We4JJ ( $$	 E
 $$T!We445O O VVsI   (3HG>	2D!H!G;6B;G61G>	6G;;G>	>H	HH"	c                   \         P                  '       d    \        P                  P	                  R4       \        R4      '       d*   \        \        P                  \        P                  R4       \        \        P                  \        P                  R4       \        R4      '       d*   \        \        P                  \        P                  R4       \        R4      '       d9   \        \        P                  \        P                  R\        P                  4       \        \        P                  \        P                  R\        P                  4       \        R4      '       d9   \        \        P                  \        P                  R\        P                  4       \        R4      '       d9   \        \        P                  \        P                  R\        P                  4       \        \        P                  \        P                  R\        P                  4       \        R4      '       d9   \        \        P                  \        P                  R\        P                  4       \        R4      '       d:   \        \        P                  \        P                  R\        P                  R7       \        \        P                  \        P                  R\        P                  \        P                  ,          R7       \        R4      '       d<   \        \        P                  \        P                  R\        P                  R7       R# R# )z:Connecting to an SSLv23 server with various client optionsr   r  FTr  )r  N)r   rm   rk   rn   ro   rJ   r  r   rG   PROTOCOL_SSLv3r|  r   r   r   r   r   r   s   &r   test_PROTOCOL_TLSThreadedTests.test_PROTOCOL_TLS  s   ???JJT"7##s//1C1CUK3++S-=-=tD7##s//1C1CWM7##s//1C1CUCL]L]^3++S-=-=tSEVEVW7##s//1C1CWcN_N_`7##s//1C1CUCL]L]^3++S-=-=tSEVEVW7##s//1C1CWcN_N_` 7##s//1C1CU*-//; 	3++S-=-=t*-//COO*K	M7##s//1C1CU.1oo? $r    r  c                f   \         P                  '       d    \        P                  P	                  R4       \        \        P                  \        P                  R4       \        \        P                  \        P                  R\        P                  4       \        \        P                  \        P                  R\        P                  4       \        \        P                  \        P                  R\        P                  R7       \        \        P                  \        P                  R4       R# )z9Connecting to an SSLv3 server with various client optionsr   r  Fr  N)r   rm   rk   rn   ro   r  r   rz  r   r   rG   r   r|  r   s   &r   test_protocol_sslv3!ThreadedTests.test_protocol_sslv3  s     ???JJT"3--s/A/A7K3--s/A/A7CL]L]^3--s/A/A7CL]L]^3--s/?/?*-//	;3--s/A/A5Ir    r  c                   \         P                  '       d    \        P                  P	                  R4       \        \        P                  \        P                  R4       \        \        P                  \        P                  R\        P                  4       \        \        P                  \        P                  R\        P                  4       \        R4      '       d*   \        \        P                  \        P                  R4       \        \        P                  \        P                  R\        P                  R7       R# )z8Connecting to a TLSv1 server with various client optionsr   r  r  Fr~  N)r   rm   rk   rn   ro   r  r   r|  r   r   rJ   rz  rG   r   r   s   &r   test_protocol_tlsv1!ThreadedTests.test_protocol_tlsv1(  s     ???JJT"3--s/A/A7K3--s/A/A7CL]L]^3--s/A/A7CL]L]^7##s1133E3EuM3--s/?/?*-//	;r    r8   c                   \         P                  '       d    \        P                  P	                  R4       \        \        P                  \        P                  R4       \        R4      '       d*   \        \        P                  \        P                  R4       \        \        P                  \        P                  R\        P                  R7       \        \        P                  \        P                  R4       \        \        P                  \        P                  R4       \        \        P                  \        P                  R4       R# )z_Connecting to a TLSv1.1 server with various client options.
Testing against older TLS versions.r   TLSv1.1r  Fr~  N)r   rm   rk   rn   ro   r  r   r}  rJ   rz  rG   r   r~  r   s   &r   test_protocol_tlsv1_1#ThreadedTests.test_protocol_tlsv1_15  s     ???JJT"3//1E1EyQ7##s33S5G5GO3//1A1A5*-*;*;	= 	3++S-A-A9M3//1E1EuM3//1E1EuMr    rS   c                T   \         P                  '       d    \        P                  P	                  R4       \        \        P                  \        P                  R\        P                  \        P                  ,          \        P                  \        P                  ,          R7       \        R4      '       d*   \        \        P                  \        P                  R4       \        \        P                  \        P                  R\        P                  R7       \        \        P                  \        P                  R4       \        \        P                  4      '       dS   \        \        P                  \        P                  R4       \        \        P                  \        P                  R4       \        \        P                   4      '       dU   \        \        P                  \        P                   R4       \        \        P                   \        P                  R4       R# R# )z_Connecting to a TLSv1.2 server with various client options.
Testing against older TLS versions.r   TLSv1.2)r  r  r  Fr~  N)r   rm   rk   rn   ro   r  r   r~  r   r   rJ   rz  rG   r   rM   r|  r}  r   s   &r   test_protocol_tlsv1_2#ThreadedTests.test_protocol_tlsv1_2E  sC    ???JJT"3//1E1Ey*-//#//*I*-//#//*I	L 7##s33S5G5GO3//1A1A5*-*;*;	= 	3++S-A-A9MC..//s33S5G5GOs1133G3GOC0011s33S5I5I5Qs33S5I5I5Q 2r    c                   Rp\        \        RRRR7      pRpT;_uu_ 4        \        P                  ! 4       pVP                  R4       VP	                  \
        VP                  34       \        P                  '       d    \        P                  P                  R4       V EF  p\        P                  '       d'   \        P                  P                  RV,          4       V'       d#   XP                  V4       VP                  4       pM"VP                  V4       VP                  R4      pVP                  4       P!                  4       pVR8X  dd   VP#                  R	4      '       dM   \        P                  '       d'   \        P                  P                  R
V,          4       \%        V4      pRpEK  VR8X  di   VP#                  R	4      '       dR   \        P                  '       d'   \        P                  P                  RV,          4       XP'                  4       pRpEK  \        P                  '       g   EK  \        P                  P                  RV,          4       EK  	  \        P                  '       d    \        P                  P                  R4       V'       d   XP                  R4       MVP                  R4       V'       d   XP)                  4        MVP)                  4        RRR4       R#   + '       g   i     R# ; i)z6Switching from clear text to encrypted and back again.rm  ro  T)rz  r]  r|  Fr   r  r,  s   okz/ client:  read %r from server, starting TLS...
z- client:  read %r from server, ending TLS...
z client:  read %r from server
r  r  N)s   msg 1s   MSG 2rm  s   MSG 3s   msg 4ro  s   msg 5s   msg 6)r:  r   r   rx  r  r,  r3  r   rm   rk   rn   ro   r1   rj  rf  r{  r%  rE   r   r  r  )	r   msgsr2  wrappedr   r   r  r  r  s	   &        r   test_starttlsThreadedTests.test_starttls[  s   c#H48+/59; VAMM$IItV[[)*

  &???JJ$$3f<>JJv&"iikGFF6NffTlGmmo++-[(S^^E-B-B

((N!"# ,A.D"Gy(S^^E-B-B

((L!"# A#G

((=CE; > 

  !BC

9%y!

	] VVVsF   CK;)A?K;)K;?AK;K;)AK;=A K;>&K;%*K;!K;;L	c                T   \        V \        R7      p\        P                  '       d    \        P
                  P                  R4       \        \        R4      ;_uu_ 4       pVP                  4       pRRR4       RpRVP                   R2p\        P                  \        R7      p\        P                  P!                  WVR	7      p VP#                  4       P%                  R
4      pV'       dr   \'        V4      ^ 8  db   VP                  \'        V4      4      p\        P                  '       d2   \        P
                  P                  R\)        V4      V3,          4       VP+                  4        V P-                  XV4       R#   + '       g   i     EL; i  TP+                  4        i ; i)z8Using socketserver to create and manage SSL connections.r  r   rbNrX  zhttps://localhost:z/test_ssl.pyr  r9  zcontent-lengthz/ client: read %d bytes from remote server '%s'
)rK  r   r   rm   rk   rn   ro   r0   r   r1   r3  r   r@  r   urllibrequesturlopeninfor   rE  rK   r  r   )r   r2  r3   r8  r:  urlr   dlens   &       r   test_socketserverThreadedTests.test_socketserver  s$   "4/B???JJT"(D!!QB ""6;;-|<,,J,?NN""3"8		668<< 01DTQVVCI&???JJ$$Jr7F+,- GGIR # "!!  GGIs   FBF F	F'c                Z   \         P                  '       d    \        P                  P	                  R4       Rp\        \        4      pT;_uu_ 4        \        \        P                  ! 4       4      pVP                  RVP                  34       \         P                  '       d'   \        P                  P	                  RV,          4       VP	                  V4       VP                  4       p\         P                  '       d'   \        P                  P	                  RV,          4       WAP                  4       8w  dK   V P                  RVR,          \        V4      VR,          P                  4       \        V4      3,          4       VP	                  R4       \         P                  '       d    \        P                  P	                  R	4       VP                  4        \         P                  '       d    \        P                  P	                  R
4       RRR4       R#   + '       g   i     R# ; i)z'Check the example asyncore integration.r   r+  r*  r  r  r  r  r  r  z client:  connection closed.
N)r   rm   rk   rn   ro   r  r   r   r   r  r3  r1   r%  r4  rK   r  )r   r   r2  r   r  s   &    r   test_asyncore_server"ThreadedTests.test_asyncore_server  sS   ???JJT"#H-V 1AII{FKK01

  /&8:GGFOffhG

  !6!@A,,.(		Ks|S\c{((*CK99: GGI

  !BCGGI

  !AB) VVVs!   B.H B*H+AH0HH*	c                :  a \         P                  '       d    \        P                  P	                  R4       \        \        \        P                  \        P                  \        RRR7      pT;_uu_ 4        \        \        P                  ! 4       R\        \        \        P                  R7      oSP                  \        VP                  34       V3R lpV3R lpRSP                  R. \         3R	SP"                  RR
.\         3RSP$                  R. R 3.pRSP&                  R. 3RSP(                  RR
.3RVR. 3RVR. 3.pRpV F  w  rxrpWg,           P+                  R4      p V! V.V
O5!  pRP-                  V4      pV P/                  W! V4      VR7       SP1                  4       pWP3                  4       8w  dG   V P5                  RP-                  WR,          \!        V4      VR,          \!        V4      R7      4       K  K  	  V F  w  pprWg,           P+                  R4      p SP                  V4       V! V
!  pWP3                  4       8w  dG   V P5                  RP-                  WR,          \!        V4      VR,          \!        V4      R7      4       K  K  	  RpSP                  V4       \=        \!        V4      4      pV P/                  SP1                  R!V4      \!        V4      4       V P/                  VV4       \>        ec   \>        P@                  \!        V4      ,          pVPC                  V4      pSP%                  V4       V P/                  SP1                  4       V4       V PE                  \F        SPH                  4       V PE                  \F        SPJ                  R.4       V PE                  \F        SPL                  ^d4       V PE                  \F        SPN                  \=        ^d4      .4       SP	                  R 4       V PE                  \6        SP&                  R!4       V PE                  \6        SP0                  R!4       SPQ                  4        RRR4       R#   \6         d   pT	'       d"   T P5                  RP-                  TR7      4       \9        T4      P;                  T4      '       g*   T P5                  RP-                  TTR7      4        Rp?EK   Rp?EK  Rp?ii ; i  \6         d   pT	'       d"   T P5                  RP-                  TR7      4       \9        T4      P;                  T4      '       g#   T P5                  RP-                  TTR7      4       SP1                  4         Rp?EKv  Rp?ii ; i  + '       g   i     R# ; i)"z Test recv(), send() and friends.r   TFr  r  r  r]  r|  r   r   r}   r|   c                  F   < \        R4      p SP                  V 4      pV RV #     Nsd                                                                                                       )r   rg  )br  r   s     r   
_recv_into0ThreadedTests.test_recv_send.<locals>._recv_into  s&    i(A%y r    c                  J   < \        R4      p SP                  V 4      w  rV RV # r  )r   ri  )r  r  rR  r   s      r   _recvfrom_into4ThreadedTests.test_recv_send.<locals>._recvfrom_into  s)    i(ooa0%y r    rj  rk  zsome.addressr  c                     R # r?   r@   )rJ  s   &r   <lambda>.ThreadedTests.test_recv_send.<locals>.<lambda>  s    4r    rf  rh  rg  ri  PREFIX_asciizsending with {}r  zpWhile sending with <<{name:s}>> bad data <<{outdata:r}>> ({nout:d}) received; expected <<{indata:r}>> ({nin:d})
r  )r   r  noutr   ninz>Failed to send with method <<{name:s}>>; expected to succeed.
r   zFMethod <<{name:s}>> failed with unexpected exception message: {exp:s}
)r   expNzrWhile receiving with <<{name:s}>> bad data <<{outdata:r}>> ({nout:d}) received; expected <<{indata:r}>> ({nin:d})
zAFailed to receive with method <<{name:s}>>; expected to succeed.
re  r  r  ))r   rm   rk   rn   ro   r:  r   r   r   rH   r   r   r  r,  r3  rj  rK   rk  r  rf  rh  r  formatr   r1   r%  r4  r   rD   rE   r   ctypesc_ubytefrom_buffer_copyr   rl  rm  rn  ro  rp  r  )r   r2  r  r  send_methodsrecv_methodsdata_prefix	meth_name	send_methr  r]   ret_val_methr   r  r  r  rk  	recv_methr   bufferubyte	bytesliker   s   &                     @r   test_recv_sendThreadedTests.test_recv_send  s   ???JJT"#H-0]]030G0G,4+/5:< V ,1)1)1*---	9A
 IItV[[)*!
! r3/188U^,<cBAIItR@L r*QZZ0@Aj$3 .%<	L $K &2"~ %199'B#F2T2C+229=C$$S,v*>C$HffhG,,.0		BBH&%.%(\'-c{F CI C 1 &2> ?K:	9n%199'BFF6N'.G,,.0		BBH&%.%(\'-c{F CI C 1 ?K@ DFF4Ls4y)FQVVB/T;VT* !T2!2248			)$  40
 115591199wiH1199cB1nny~.>@GGIj!&&"5j!&&"5GGIw Vf " %		55;VV5K q6,,Y77		;;A6%.A <B <  8: " %		55;VV5K q6,,Y77		;;A6%.A <B < FFHHa VVsf   6C0V	'BQ(&V	*A/S4GV	(S1	3A+S,	V	,S1	1V	4V	?A;V	:V	V	V		V	c                   \        \        4      pV P                  V4       \        P                  ! \
        VP                  34      pV P                  VP                  4       \        VR R7      pV P                  VP                  4       VP                  R4       V P                  VP                  ^ 4      R4       V P                  VP                  ^ 4      R4       V P                  VP                  4       R4       VP                  R 4       V P                  VP                  ^ 4      R4       V P                  VP                  \!        4       4      ^ 4       R# )Frd  re  r    N)r:  r   r  r   rw  r,  r3  r  r  r   rj  r   rf  r1   rx  rg  r   )r   r2  r   s   &  r   test_recv_zeroThreadedTests.test_recv_zeroS  s    #H-&!$$dFKK%89 QU;  	
wC(C(7+ 	
eC(Y[115r    c                   \        \        4      pV P                  V4       \        P                  ! \
        VP                  34      pV P                  VP                  4       \        VR R7      pV P                  VP                  4       VP                  R4       \        P                  ! R^ ^ .4      pV P                  VP                  V4      ^4       V P                  \        V4      R,          R4        ! R R\        4      pVP                  R4       V! ^4      pV P                  VP                  V4      ^4       V P                  \        V4      R4       R# )	Fr  re  I:Nr  Nc                   &   a  ] tR tRt o R tRtV tR# );ThreadedTests.test_recv_into_buffer_protocol_len.<locals>.Bis  c                    ^^ ,           R# rc  Nr@   r   s   &r   __len__CThreadedTests.test_recv_into_buffer_protocol_len.<locals>.B.__len__t  s    !r    r@   N)r  r>  r?  r@  r  rF  rG  rH  s   @r   Br  s  s      r    r  s   data  N)r:  r   r  r   rw  r,  r3  r  r  r   rj  arrayr   rg  r  r   )r   r2  r   r  r  s   &    r   "test_recv_into_buffer_protocol_len0ThreadedTests.test_recv_into_buffer_protocol_lenf  s    #H-&!$$dFKK%89 QU; 	wkk#1v&S)1-sB1		 	 	
wdS)1-s[1r    c           
     ^  aa \        \        \        P                  \        P                  \        R RR7      pV;_uu_ 4        \        \        P                  ! 4       R\        \        \        P                  R7      oSP                  \        VP                  34       SP                  R4       \        R4      oVV3R lpV P                  \        P                  \        P                  3V4       SP                  R 4       SP                  4        RRR4       R#   + '       g   i     R# ; i)TFr  r  i    c                  ,   <  SP                  S 4       K  T)rj  )r  r   s   r   fill_buffer8ThreadedTests.test_nonblocking_send.<locals>.fill_buffer  s    FF3Kr    N)r:  r   r   r   rH   r   r   r  r,  r3  rx  r   r   r  ry  r  )r   r2  r  r  r   s   &  @@r   test_nonblocking_send#ThreadedTests.test_nonblocking_send{  s    #H-0]]030G0G,4+/5:< V ,1)1)1*---	9A
 IItV[[)*MM%  D/C  s44"3356AC MM$GGI) VVVs   CDD,	c                  aaa \         P                   ! \         P                  4      oR p\        P                  ! S4      p\        P
                  ! 4       oRoVVV3R lp\        P                  ! VR7      pVP                  4        SP                  4          \         P                   ! \         P                  4      pVP                  R4       VP                  W34       V P                  \        R\        V4       VP                  4         \         P                   ! \         P                  4      p\        V4      pVP                  R4       V P                  \        RVP                  W34       VP                  4         RoVP                  4        SP                  4        R#   XP                  4        i ; i  TP                  4        i ; i  RoTP                  4        SP                  4        i ; i)r*  Fc                  *  < SP                  4        SP                  4        . p S'       gO   \        P                  ! S.. . R 4      w  rpSV9   g   K.  V P                  SP	                  4       ^ ,          4       KV  V  F  pVP                  4        K  	  R# )r  N)r  r  r  r  r  r  )connsr/  wrk  r   finishr2  starteds        r   serve3ThreadedTests.test_handshake_timeout.<locals>.serve  sj    MMOKKME --"b#>aQ; LL!34

 r    r   r  z	timed outTN)r   rY  r   r*  rT  r  r   r  r  rv  r  r   r  r   r  r   )	r   r  r3  r  rL  r  r  r2  r  s	   &     @@@r   test_handshake_timeout$ThreadedTests.test_handshake_timeout  sZ   v~~.&&v.//#	 E*			MM&..1S!		4,'&&|['7< 	MM&..1$Q'S!&&|['(yy4,@ 	FFFHLLN 	 	FFFHLLNs8   A#F$ ;G A#F9 /G $F66G 9GG $G2c                d  a
aaa \        4       w  rp\        P                  ! \        P                  4      oR p\        P                  ! S4      pVP                  SRR7      oV P                  SP                  4       \        P                  ! 4       o
RoRoV
VVV3R lp\        P                  ! VR7      pVP                  4        S
P                  4        VP                  \        P                  ! 4       VR7      pVP                  W534       VP                  R4       VP                  4        VP!                  4       p	VP#                  4        VP%                  4        SP#                  4        SP#                  4        V P'                  S\(        P*                  4       V P-                  SV	4       R# )r*  TrY  Nc                     < SP                  4        S P                  4        SP                  4       w  ooSP                  SP	                  ^4      4       R# )r  N)r  r  r  rj  rf  )evtpeerremoter2  s   r   r  /ThreadedTests.test_server_accept.<locals>.serve  s8    MMOGGI!==?LFDKKA'r    r   r  re  )r   r   rY  r   r*  r   r  r   rT  r  r   r  r  r  rj  rf  r  r  r   rD  r   r   r   )r   r  r  r   r  r3  r  rL  r  client_addrr  r  r  r2  s   &         @@@@r   test_server_accept ThreadedTests.test_server_accept  s@    ,;+<(
v~~.&&v.''D'A**+oo	( 	( E*		
''MMOX ( 
 	'(G((*	fcmm4{+r    c           	        \         P                  \         P                  4      pR Vn        VP	                  \
        P
                  ! 4       4      ;_uu_ 4       pV P                  \        4      ;_uu_ 4       pVP                  4        RRR4       V P                  XP                  P                  \        P                  4       RRR4       R#   + '       g   i     LN; i  + '       g   i     R# ; ir  )r   rT   rI   r   r   r   r   re  r  r   rl   r-  ENOTCONNr   r   r   r  s   &   r   test_getpeercert_enotconn'ThreadedTests.test_getpeercert_enotconn  s    ..!8!89!&  11T""7++r  " ,R\\//@ 21++ 211$   C5C	<CCCC0	c           	        \         P                  \         P                  4      pR Vn        VP	                  \
        P
                  ! 4       4      ;_uu_ 4       pV P                  \        4      ;_uu_ 4       pVP                  4        RRR4       V P                  XP                  P                  \        P                  4       RRR4       R#   + '       g   i     LN; i  + '       g   i     R# ; ir  )r   rT   rI   r   r   r   r   re  rz  r   rl   r-  r  r  s   &   r   test_do_handshake_enotconn(ThreadedTests.test_do_handshake_enotconn  s    ..!8!89!&  11T""7++r!!# ,R\\//@ 21++ 211r  c                   \        4       w  rp\        P                  P                  Vn        VP                  R 4       VP                  R4       \        VR7      ;_uu_ 4       pVP                  \        P                  ! 4       VR7      ;_uu_ 4       pV P                  \        4      ;_uu_ 4        VP                  \        VP                  34       RRR4       RRR4       RRR4       V P                  RXP                  ^ ,          4       R#   + '       g   i     LE; i  + '       g   i     LP; i  + '       g   i     L[; i)AES128AES256r9  r  NNO_SHARED_CIPHER)r   r   r   rS   rP   r:   r:  r   r   r   re  r  r,  r3  r  ra  r;  s   &     r   test_no_shared_ciphers$ThreadedTests.test_no_shared_ciphers  s    3B3D0),)?)?&""8,""8,776++FMMO<D , F FIJ&&w//IItV[[12 0F 8
 	(&*<*<Q*?@ 0/F F 87s<   #/D5D"	0"DD"	D5DD"	"D2-D55E	c           	        \         P                  \         P                  4      pRVn        \         P                  Vn        \        \        \         P                  RR7      ;_uu_ 4       pVP                  \        P                  ! 4       4      ;_uu_ 4       pV P                  VP                  4       R4       V P                  VP                  R4       VP                  \        VP                   34       V P#                  VP                  4       R4       RRR4       V P                  XP                  R4       V P                  VP                  4       R4       RRR4       R#   + '       g   i     LV; i  + '       g   i     R# ; i)z\
Basic tests for SSLSocket.version().
More tests are done in the test_protocol_*() methods.
F)r  r]  Nr!  )r   rT   rI   r   r   r   r:  r   rH   r   r   r   rW   r  r  r,  r3  r   )r   r   r2  r   s   &   r   test_version_basic ThreadedTests.test_version_basic  s   
 ..!8!89!&!mm,/,C,C',. .17$$V]]_55aiik40aii.		4-.  i8	 6
 MM!))T*MM!))+t,. . 65. . .s&   (-E4A>E!	AE4!E1,E44F	c           	     (   \        4       w  rp\        P                  P                  Vn        \        VR 7      ;_uu_ 4       pVP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       V P                  VP                  4       ^ ,          0 Rm4       V P                  VP                  4       R4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r9  r  r!  N>   TLS_AES_128_GCM_SHA256TLS_AES_256_GCM_SHA384TLS_CHACHA20_POLY1305_SHA256)r   r   r   r  r6   r:  r   r   r  r,  r3  r  r#  r   rW   r;  s   &     r   test_tls1_3ThreadedTests.test_tls1_3"  s    3B3D0),)?)?&776++FMMO<D , F FIJ		4-.ahhjm . 
   i8F 87F F 877s%   /D 0A+C-	D -C=8D  D	c           	        \        4       w  rp\        P                  P                  Vn        \        P                  P
                  Vn        \        P                  P
                  Vn        \        P                  P
                  Vn        \        VR 7      ;_uu_ 4       pVP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       V P                  VP                  4       R4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r9  r  r  N)r   r   r   r  r6   rS   rP   r:  r   r   r  r,  r3  r   rW   r;  s   &     r   test_min_max_version_tlsv1_2*ThreadedTests.test_min_max_version_tlsv1_21  s     4C3D0),)=)=&),)?)?&),)?)?&),)?)?&776++FMMO<D , F FIJ		4-.  i8F 87F F 877s%   /D4AD!	D4!D1,D44E	c           	        \        4       w  rp\        P                  P                  Vn        \        P                  P
                  Vn        \        P                  P                  Vn        \        P                  P                  Vn        \        W4       \        VR 7      ;_uu_ 4       pVP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       V P                  VP!                  4       R4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r9  r  r  N)r   r   r   r  r6   rS   rP   r8   r=   r:  r   r   r  r,  r3  r   rW   r;  s   &     r   test_min_max_version_tlsv1_1*ThreadedTests.test_min_max_version_tlsv1_1C  s     4C3D0),)=)=&),)?)?&),)=)=&),)?)?&N;776++FMMO<D , F FIJ		4-.  i8F 87F F 877s%   )/D?AD,	D?,D<7D??E	c                6   \        4       w  rp\        P                  P                  Vn        \        P                  P                  Vn        \        P                  P                  Vn        \        P                  P                  Vn        \        W4       \        VR 7      ;_uu_ 4       pVP                  \        P                  ! 4       VR7      ;_uu_ 4       pV P                  \        P                  4      ;_uu_ 4       pVP                  \        VP                  34       RRR4       V P!                  \#        XP$                  4      R4       RRR4       RRR4       R#   + '       g   i     LG; i  + '       g   i     L-; i  + '       g   i     R# ; i)r9  r  Nz(alert|ALERT))r   r   r   rS   rP   r6   r  r=   r:  r   r   r   r   r  r,  r3  rr  rD   rl   r`  s   &      r   test_min_max_version_mismatch+ThreadedTests.test_min_max_version_mismatchT  s    4C3D0),)?)?&),)?)?&),)=)=&),)=)=&N;776++FMMO<D , F FIJ&&s||44IItV[[12 5  Q[[!1?C	F 87 54F F 877s<   )/F(E4	 "E!"-E4	F!E1,E4	4F?FF	c           	     h   \        4       w  rp\        P                  P                  Vn        \        P                  P                  Vn        \        P                  P                  Vn        \        W4       \        VR 7      ;_uu_ 4       pVP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       V P                  VP                  4       R4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r9  r  r  N)r   r   r   r  r6   rP   r=   r:  r   r   r  r,  r3  r   rW   r;  s   &     r   test_min_max_version_sslv3(ThreadedTests.test_min_max_version_sslv3g  s    3B3D0),)=)=&),)=)=&),)=)=&N;776++FMMO<D , F FIJ		4-.  g6F 87F F 877s%   
/D 9AD	;D DD  D1	c           	        \        4       w  rp\        P                  P                  Vn        \        VR 7      ;_uu_ 4       pVP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       V P                  RVP                  4       ^ ,          4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r9  r  ECDHN)r   r   r   rS   rP   r:  r   r   r  r,  r3  r  r#  r;  s   &     r   test_default_ecdh_curve%ThreadedTests.test_default_ecdh_curveu  s     4C3D0 *-)?)?&
  776++FMMO<D , F FIJ		4-.fahhjm4F 87F F 877s%   /C0A	C	9CCCC/	r  r  c           
     0   \         P                  '       d    \        P                  P	                  R4       \        4       w  rp\        P                  P                  Vn	        \        VRRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       VP!                  R4      p\         P                  '       d/   \        P                  P	                  RP#                  V4      4       V P%                  V4       VP'                  4       R8X  d   V P)                  \+        V4      ^04       MV P)                  \+        V4      ^4       VP	                  R	4       VP-                  4       P/                  4       pV P)                  V\1        V4      P3                  R
4      4       RRR4       VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       VP!                  R4      p\         P                  '       d/   \        P                  P	                  RP#                  V4      4       V P5                  XV4       V P%                  V4       VP'                  4       R8X  d   V P)                  \+        V4      ^04       MV P)                  \+        V4      ^4       VP	                  R	4       VP-                  4       P/                  4       pV P)                  V\1        V4      P3                  R
4      4       RRR4       RRR4       R#   + '       g   i     EL; i  + '       g   i     L.; i  + '       g   i     R# ; i)z Test tls-unique channel binding.r   TFr  r  r  z! got channel binding data: {0!r}
r!  s   CB tls-unique
rp  Nz(got another channel binding data: {0!r}
)r   rm   rk   rn   ro   r   r   r   rS   rP   r:  r   r   r  r,  r3  r  r  r%  rW   r   rK   r1   r{  r   r  assertNotEqual)	r   r   r   r   r2  r   cb_datapeer_data_reprnew_cb_datas	   &        r   r  -ThreadedTests.test_tls_unique_channel_binding  s    ???JJT"3B3D0 *-)?)?&#N+/5:< V++MMO$, , . .12		4-.//=???JJ$$<CCGLN $$W-99;)+$$S\26$$S\26 *+!"!1  !%g!5!5j!AC).0  ++MMO$, , . .12		4-.33LA???JJ$$CJJ')
 ##G[9$$W-99;)+$$S\26$$S\26*+!"!1  !%k!2!9!9*!EG'.3 V. . .0. .3 VVs>   :/N)D-M	6ND?M1	NM.(	N1N<NN	c                
   \        4       w  rp\        WR R VR7      p\        P                  '       d6   \        P
                  P                  RP                  VR,          4      4       V P                  VR,          0 Rm4       R# )Tr]  r|  r  z got compression: {!r}
r  N>   NRLEZLIB)	r   r  r   rm   rk   rn   ro   r  r  r   r   r   r   r7  s   &    r   test_compressionThreadedTests.test_compression  se    3B3D0">*.,46 ???JJ7>>u]?STUeM*,CDr    r(   z*ssl.OP_NO_COMPRESSION needed for this testc                   \        4       w  rpV;P                  \        P                  ,          un        V;P                  \        P                  ,          un        \	        WR R VR7      pV P                  VR,          R4       R# )Tr  r  N)r   r  r   r(   r  r   r   s   &    r   test_compression_disabled'ThreadedTests.test_compression_disabled  si     4C3D0#"7"77#"7"77">*.,46 	eM*D1r    c                    \        4       w  rpV;P                  \        P                  ,          un        \	        WR R VR7       R# Tr  Nr   r  r   r<  r  r   r   r   r   s   &   r   test_legacy_server_connect(ThreadedTests.test_legacy_server_connect  s8    3B3D0#">">>>*.,4	6r    c                    \        4       w  rpV;P                  \        P                  ( ,          un        \	        WR R VR7       R# r'  r(  r)  s   &   r   test_no_legacy_server_connect+ThreadedTests.test_no_legacy_server_connect  s;    3B3D03#?#?"??>*.,4	6r    c                   \        4       w  rp0 R
mp\        W4      '       d   \        W$4      '       g   V P                  R4       \        P                  P
                  Vn         VP                  \        4       TP                  R4       \        P                  P
                  Tn        \        YRRTR7      pTR,          ^ ,          pTP                  R4      pTP                  T4      '       g"   T P                  RT^ ,          ,           4       R	# R	#   \         d     \        '       d   T P                  R4       h i ; i)ADHz#libssl doesn't support ephemeral DHr  kEDHTr  r#  rC  zNon-DH key exchange: N>   r0  DHEEDH)r   r  r&  r   r   rS   rP   r  r  r  r  r:   r  rH  rq  r4  )r   r   r   r   dhe_aliasesr7  r#  partss   &       r   test_dh_paramsThreadedTests.test_dh_params  s    4C3D0+!.>>%nBBMM?@),)?)?&	))&1
 	""6*),)?)?&">*.,46 x#S!''..II-q	9: /  	~BC	s   %D D>+D>c           
        \        4       w  rpVP                  R 4       VP                  R4       \        P                  P
                  Vn        \        WRRVR7      p\        4       w  rpVP                  R 4       VP                  R4       \        P                  P
                  Vn        \        WRRVR7      p\        4       w  rpVP                  R4       VP                  R 4       VP                  R4       \        P                  P
                  Vn        V P                  \        P                  4      ;_uu_ 4        \        WRRVR7       RRR4       R#   + '       g   i     R# ; i)	secp384r1zECDHE:!eNULL:!aNULLTr  r  N)
r   r  r:   r   r   rS   r6   r  r   r   r   s   &    r   test_ecdh_curveThreadedTests.test_ecdh_curve  s(   3B3D0%%k2""#89),)?)?&">*.,46
 4C3D0%%k2""#89),)?)?&">*.,46
 4C3D0%%l3%%k2""#89),)?)?&s||,,~&*T(02 -,,,s   EE,	c                p    \        4       w  rp\        WR R VR7      pV P                  VR,          R4       R# )Tr  r  N)r   r  r   r   s   &    r   test_selected_alpn_protocol)ThreadedTests.test_selected_alpn_protocol!  s9    3B3D0">*.,46 	e23T:r    c                    \        4       w  rpVP                  R R.4       \        WRRVR7      pV P                  VR,          R4       R# )r  barTr  r  N)r   r  r  r   r   s   &    r   /test_selected_alpn_protocol_if_server_uses_alpn=ThreadedTests.test_selected_alpn_protocol_if_server_uses_alpn)  sK    3B3D0))5%.9">*.,46 	e23T:r    c           	     8   . ROpR R.R 3RR .R 3R.R3RR.R3.pV F  w  r4\        4       w  rVpVP                  V4       VP                  V4        \        VVRRVR7      pR\        V4      : R	\        V4      : R
\        V4      : R2p
VR,          pV P                  WWR3,          4       \        VR,          4      '       d   VR,          R,          MRpV P                  WWR3,          4       K  	  R#   \        P                   d   p	T	p Rp	?	LRp	?	ii ; i)r  r@  	milkshakezhttp/3.0zhttp/4.0NTr  zfailed trying z	 (s) and z (c).
was expecting z, but got %s from the %sr  r  r  nothingr2  )r  r@  rD  r  )r   r  r  r   r   rD   r   rK   )r   server_protocolsprotocol_testsclient_protocolsr  r   r   r   r7  rk  r  client_resultserver_results   &            r   r%  !ThreadedTests.test_alpn_protocols2  sA   6U^U#U^U#]K(*%t,	
 +9&7F7H4NH--.>?--.>?*>+926<@4<	> +,c2B.CH'C ""89M] 8#<<> u4566 ""9:2><E ] 8#<<>/ +9 << s   C88DDDc                6    \         P                  '       d   Q hR # r?   )r   HAS_NPNr   s   &r   test_npn_protocols ThreadedTests.test_npn_protocolsT  s    ;;;;r    c                Z   \         P                  \         P                  4      pVP                  \        4       \         P                  \         P                  4      pVP                  \
        4       \         P                  \         P                  4      pVP                  \        4       WV3# r?   )	r   rT   rH   r   r   r   rI   r   r   )r   r   other_contextr   s   &   r   sni_contextsThreadedTests.sni_contextsW  st    (?(?@&&7s'>'>?%%&67(?(?@,,Z8n<<r    c                P    VR ,          pV P                  RV33VR,          4       R# )r  r  r  N)r  )r   r7  r   r  s   &&& r   check_common_nameThreadedTests.check_common_name`  s&    Z d+-tI?r    c                  aa . oV P                  4       w  popR Vn        VV3R lpVP                  V4       \        W!RRR7      pV P	                  SRV3.4       V P                  VR4       . o\        W!RRR7      pV P	                  SRV3.4       V P                  V\        4       . oVP                  R4       \        W!RRR7      pV P                  V\        4       V P	                  S. 4       R# )Fc                 F   < SP                  W34       Ve
   SV n        R # R # r?   )r  r   )r  r  r  callsrQ  s   &&&r   r  6ThreadedTests.test_sni_callback.<locals>.servername_cbj  s%    LL+78&#0  'r    Tsupermessager]  r  r$   Nnotfunny)rR  r   r  r  r   rU  r   )r   r   r   r  r7  rY  rQ  s   &    @@r   r  ThreadedTests.test_sni_callbackd  s   8<8I8I8K5~(-%	1 	..}=">*.,:<
 	..!A BCun5">*.,02 	$!7 89u&>? ..t4">*.,68 	u&>?#r    c           	     B   V P                  4       w  rpR  pVP                  V4       V P                  \        P                  4      ;_uu_ 4       p\        W1RRR7      pRRR4       V P                  XP                  P                  R4       R#   + '       g   i     L8; i)c                 "    \         P                  # r?   )r   ALERT_DESCRIPTION_ACCESS_DENIEDr  s   &&&r   cb_returning_alertAThreadedTests.test_sni_callback_alert.<locals>.cb_returning_alert  s    666r    Fr[  r\  NTLSV1_ALERT_ACCESS_DENIED)	rR  r  r   r   r   r  r   rl   rs  )r   r   rQ  r   rb  r  r7  s   &      r   test_sni_callback_alert%ThreadedTests.test_sni_callback_alert  s~    8<8I8I8K5~	7../ABs||,,&~.30>@E - 	,,.IJ	 -,s   BB	c                   V P                  4       w  rpR  pVP                  V4       \        P                  ! 4       ;_uu_ 4       pV P	                  \
        P                  4      ;_uu_ 4       p\        W1RRR7      pRRR4       RpV P                  XP                  P                  V4       V P                  VP                  P                  \        4       RRR4       R#   + '       g   i     Ll; i  + '       g   i     R# ; i)c                     ^^ ,           R# r  r@   r  s   &&&r   
cb_raising;ThreadedTests.test_sni_callback_raising.<locals>.cb_raising  s    aCCr    Fr[  r\  Nz0(SSLV3_ALERT_HANDSHAKE_FAILURE|NO_PRIVATE_VALUE))rR  r  r   catch_unraisable_exceptionr   r   r   r  rr  rl   rs  r   
unraisableexc_typeZeroDivisionError)	r   r   rQ  r   ri  catchr  r7  r  s	   &        r   test_sni_callback_raising'ThreadedTests.test_sni_callback_raising  s    8<8I8I8K5~	..z://11U""3<<00B*>274BD 1 GER\\00%8U--668IJ 2100 211s%   (C3-C 	<AC3 C0+C33D	c                
   V P                  4       w  rpR  pVP                  V4       \        P                  ! 4       ;_uu_ 4       pV P	                  \
        P                  4      ;_uu_ 4       p\        W1RRR7      pRRR4       V P                  XP                  P                  R4       V P                  VP                  P                  \        4       RRR4       R#   + '       g   i     Lj; i  + '       g   i     R# ; i)c                     R # )r  r@   r  s   &&&r   cb_wrong_return_typeOThreadedTests.test_sni_callback_wrong_return_type.<locals>.cb_wrong_return_type  s    r    Fr[  r\  NTLSV1_ALERT_INTERNAL_ERROR)rR  r  r   rk  r   r   r   r  r   rl   rs  rl  rm  r   )r   r   rQ  r   rt  ro  r  r7  s   &       r   #test_sni_callback_wrong_return_type1ThreadedTests.test_sni_callback_wrong_return_type  s     9=8I8I8K5~	../CD//11U""3<<00B*>274BD 1 R\\002NOU--66	B 2100 211s%   (C1-C	<AC1C.)C11D	c                  a	 \        4       w  rpVP                  R 4       VP                  R4       . ROp\        WVR7      pVR,          ^ ,          pV P                  \	        V4      ^ 4       V FY  w  o	rx\
        ;QJ d    V	3R lV 4       F  '       g   K   RM	  RM! V	3R lV 4       4      '       d   KH  V P                  S	4       K[  	  R# )	zAES128:AES256zAES256:eNULLr  r  c              3   ,   <"   T F	  qS9   x  K  	  R # 5ir?   r@   )rf  algr   s   & r   rg  4ThreadedTests.test_shared_ciphers.<locals>.<genexpr>  s     <msd{ms   TFN)r  zAES-256TLS_CHACHA20TLS_AES)r   r:   r  assertGreaterrK   anyr4  )
r   r   r   r   expected_algsr7  r~   tls_versionbitsr   s
   &        @r   test_shared_ciphers!ThreadedTests.test_shared_ciphers  s    3B3D0""?3"">2
 #>,46/033w<+'.#D+3<m<333<m<<<		$ (/r    c                   \        4       w  rp\        VR R7      pV;_uu_ 4        VP                  \        P                  ! 4       VR7      pVP	                  \
        VP                  34       VP                  4        V P                  \        VP                  R4       V P                  \        VP                  R4       RRR4       R#   + '       g   i     R# ; i)Fr2  r  r,  s   helloN)r   r:  r   r   r  r,  r3  r  r   r   r1   ro   r;  s   &     r   ,test_read_write_after_close_raises_valuerror:ThreadedTests.test_read_write_after_close_raises_valuerror  s    3B3D0#N5IV**6==?;C + EAIItV[[)*GGIj!&&$7j!''8< VVVs   BC		C	c                >   Rp\        \        P                  R4      ;_uu_ 4       pVP                  V4       RRR4       V P	                  \        P
                  \        P                  4       \        4       w  r4p\        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       \        \        P                  R4      ;_uu_ 4       pVP                  V4       V P                  VP                  R4      V4       RRR4       RRR4       RRR4       R#   + '       g   i     EL#; i  + '       g   i     L6; i  + '       g   i     LA; i  + '       g   i     R# ; i)	rd  wbNFr2  r  r  r,  s   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)r0   r   TESTFNro   r  unlinkr   r:  r   r   r  r,  r3  sendfiler   rf  )	r   	TEST_DATAr3   r   r   r   r2  r   files	   &        r   test_sendfileThreadedTests.test_sendfile  s   	)""D))QGGI *	(()*:*:;3B3D0#N5IV++FMMO<D , F FIJ		4-.)**D11TJJt$$$QVVD\9= 2F V *)) 21F F VVsH   E/F AE8	3E%7E8	?FE"	%E50E8	8FFF	c                   \        4       w  rp\        P                  P                  Vn        \        WVR 7      pVR,          pV P                  VP                  4       V P                  VP                  ^ 4       V P                  VP                  ^ 4       V P                  VP                  4       V P                  VP                  ^ 4       V P                  VR,          4       VP                  4       pV P                  VR,          ^4       V P                  VR,          ^ 4       \        WWSR7      pVP                  4       pV P                  VR,          ^4       V P                  VR,          ^4       V P                  VR,          4       VR,          pV P                  VP                  VP                  4       V P                  Wu4       V P!                  Wu4       V P#                  VP                  VP                  4       V P#                  VP                  VP                  4       \        WVR 7      pV P                  VR,          4       VR,          pV P%                  VP                  VP                  4       V P%                  W4       VP                  4       pV P                  VR,          ^4       V P                  VR,          ^4       \        WWSR7      pV P                  VR,          4       VR,          p	V P                  V	P                  VP                  4       V P                  W4       V P#                  V	P                  VP                  4       V P#                  V	P                  VP                  4       VP                  4       pV P                  VR,          ^4       V P                  VR,          ^4       R# )rz  r  r  r  r  )r  r  N)r   r   r   rS   rP   r  r  idr  rt   rx  
has_ticketticket_lifetime_hintr}  r  r   assertIsNotr   r  )
r   r   r   r   r7  r  	sess_statsession2session3session4s
   &         r   test_sessionThreadedTests.test_session  s   3B3D0),)?)?& #>,46	"

#7<<+7??A.**+777;/01"002	8,a06*A. #>+2G"002	8,a06*A../0#gjj1++w||< 0 0'//B #>,46/01#HKK4H."002	8,a06*A. #>+2G./0#gjj1+w||< 0 0'//B"002	8,a06*A.r    c                p   \        4       w  rp\        4       w  p p\        P                  P                  Vn        \        P                  P                  Vn        \        VR R7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pV P                  VP                  R4       V P                  VP                  R4       VP                  \        VP                  34       VP                  pV P                  V4       V P                  \         4      ;_uu_ 4       p	\"        Vn	        RRR4       V P                  \%        X	P&                  4      R4       RRR4       VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       V P                  \(        4      ;_uu_ 4       p	XVn	        RRR4       V P                  \%        X	P&                  4      R4       RRR4       VP                  \        P                  ! 4       VR7      ;_uu_ 4       pXVn	        VP                  \        VP                  34       V P                  VP                  P*                  VP*                  4       V P                  VP                  V4       V P                  VP                  R4       RRR4       VP                  \        P                  ! 4       VR7      ;_uu_ 4       pV P                  \(        4      ;_uu_ 4       p	XVn	        VP                  \        VP                  34       RRR4       V P                  \%        X	P&                  4      R4       RRR4       RRR4       R#   + '       g   i     ELc; i  + '       g   i     ELJ; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)Fr2  r  NzValue is not a SSLSession.z#Cannot set session after handshake.Tz)Session refers to a different SSLContext.)r   r   r   rS   rP   r:  r   r   r   r  r  r  r,  r3  r  r   r   r  rD   rl   r   r  )
r   r   r   r   client_context2r  r2  r   r  rk  s
   &         r   test_session_handling#ThreadedTests.test_session_handling&  s"   3B3D0 / 1A *-)?)?&*-..*@*@'#N5IV++FMMO<D , F FIJ  D1  !1!148		4-.))(&&y11Q &AI 2  Q[[!13OPF  ++FMMO<D , F FIJ		4-.&&z22a 'AI 3  Q[[!1!FHF  ++FMMO<D , F FIJ $			4-.  wzz:  G4  !1!148F !,,V]]_=E - G GJK&&z22a 'AIIItV[[12 3   Q[[!1!LNGA V 211F F F  322	F F FF F F 32G GA VVs   1/P$ BN.	4N -N.	-6P$#?O	"O*-O	6P$BO*	6P$P	2)O>-P	P$N+%	N.	.N?9	P$O	O	O'!	P$*O;5	P$>P	P	P!P$$P5	z&TLS-PSK disabled on this OpenSSL buildc                	  a aaa	a
 \         P                  R 4      o
\        P                  \        P                  4      pRVn        \        P                  Vn        \        P                  P                  Vn
        VP                  R4       VP                  V
3R l4       \        P                  \        P                  4      p\        P                  P                  Vn
        VP                  R4       VP                  V
3R l4       \        VR7      pT;_uu_ 4        VP!                  \"        P"                  ! 4       4      ;_uu_ 4       pVP%                  \&        VP(                  34       RRR4       RRR4       \         P                  R4      o	VP                  V	3R l4       \        VR7      pT;_uu_ 4        VP!                  \"        P"                  ! 4       4      ;_uu_ 4       pS P+                  \        P,                  4      ;_uu_ 4        VP%                  \&        VP(                  34       RRR4       RRR4       RRR4       R	oR
oVVV
V 3R lpVV
V 3R lpVP                  V4       VP                  VS4       \        VR7      pT;_uu_ 4        VP!                  \"        P"                  ! 4       4      ;_uu_ 4       pVP%                  \&        VP(                  34       RRR4       RRR4       S P/                  \        P,                  R4      ;_uu_ 4        VP                  VS4       RRR4       S P/                  \        P,                  R4      ;_uu_ 4        VP                  V4       RRR4       RoRoVP                  V4       VP                  VS4       \        VR7      pT;_uu_ 4        VP!                  \"        P"                  ! 4       4      ;_uu_ 4       pVP%                  \&        VP(                  34       RRR4       RRR4       R#   + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL%; i  + '       g   i     EL1; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL}; i  + '       g   i     ELO; i  + '       g   i     L; i  + '       g   i     R# ; i)deadbeefFrY  c                    < R S3# r?   r@   )hintpsks   &r   r  (ThreadedTests.test_psk.<locals>.<lambda>b  s	    T3Kr    c                    < S# r?   r@   )identityr  s   &r   r  r  g  s    r    r9  Ncafebabec                    < R S3# r?   r@   )r  incorrect_psks   &r   r  r  q  s
    T=<Qr    identity-hintclient-identityc                 0   < SP                  V S4       SS3# r?   r   )r  client_identityidentity_hintr  r   s   &r   client_callback/ThreadedTests.test_psk.<locals>.client_callback|  s    T=1"C''r    c                 ,   < SP                  V S4       S# r?   r  r  r  r  r   s   &r   server_callback/ThreadedTests.test_psk.<locals>.server_callback      X7Jr    zCannot add PSK server callbackzCannot add PSK client callbacku   身份暗示u   客户身份)r  fromhexr   rT   rI   r   r   r   r   rS   rP   r:   set_psk_client_callbackrH   set_psk_server_callbackr:  r   r   r  r,  r3  r   r   r   )r   r   r   r2  r   r  r  r  r  r  r  s   f      @@@@r   test_pskThreadedTests.test_pskX  s@    mmJ'(?(?@(-%%(]]"),)?)?&""5)../GH(?(?@),)?)?&""5)../CD $N;V++FMMO<<		4-. = 
 j1../QR#N;V++FMMO<<&&s||44IItV[[12 5 =  (+	( 	(	 	..?..N#N;V++FMMO<<		4-. = 
 ##CLL2RSS22?MR T##CLL2RSS22?C T '(..?..N#N;V++FMMO<<		4-. = VY =<< VV 544 =<< VV* =<< VV
 TSSSSS =< VVs   -P/
"P	,P/<-Q+)(Q	"Q3Q	;Q+-R"Q?	(R R'#R;:-S"'"S		S"P,&	P//Q 	Q	Q	Q("	Q++Q<	?R
	RR$	'R8	;S	SS""S3	c           	     ^  a aa	 \         P                  R 4      o	RpRoVV	V 3R lpVV	V 3R lp\        P                  \        P                  4      pRVn        \        P                  Vn        \        P                  P                  Vn
        VP                  R4       VP                  V4       \        P                  \        P                  4      p\        P                  P                  Vn
        VP                  R4       VP                  W14       \        VR7      pT;_uu_ 4        VP!                  \"        P"                  ! 4       4      ;_uu_ 4       pVP%                  \&        VP(                  34       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)	r  r  r  c                 .   < SP                  V 4       SS3# r?   )r  )r  r  r  r   s   &r   r  6ThreadedTests.test_psk_tls1_3.<locals>.client_callback  s    d#"C''r    c                 ,   < SP                  V S4       S# r?   r  r  s   &r   r  6ThreadedTests.test_psk_tls1_3.<locals>.server_callback  r  r    FrY  r9  N)r  r  r   rT   rI   r   r   r   r   r  r6   r:   r  rH   r  r:  r   r   r  r,  r3  )
r   r  r  r  r   r   r2  r   r  r  s
   f       @@r   test_psk_tls1_3ThreadedTests.test_psk_tls1_3  s    mmJ''+	(
	 (?(?@(-%%(]]"),)?)?&""5)..?(?(?@),)?)?&""5)..N#N;V++FMMO<<		4-. = V<< VVs$   '-F"F	6FFFF,	r@   Nr  )Qr  r>  r?  r@  r   rE  r  r[   rB  Py_GIL_DISABLEDr/  r&  r'  rK  r   r  r  rJ  rR   rP  rS  r)  r*  rf   r+  rq  rw  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rd  r  r
  r  r  r  rC  r  r!  r7   r$  r*  r-  r6  r:  r=  rA  r%  rN  rR  rU  r  re  rp  rw  r  r  r  r  r  HAS_PSKr  r  rF  rG  rH  s   @r   r  r  
  s    z**" +*"X 002^_'* `'*R"/H+EZ#2J '')T33*@* )MOEOE<@4N`#EJ )$ %8'R5>?B '"	J #	J '"
; #
; )$N %N )$R %R*7r!4C:FP6&2*:/b&,PAAA-& )$9 %9 )$'"9  # %9 )$9  %9 )$'"D  # %D  '"7 #75" )B)BBEG<GG<G|E &9:EG2G266;42>;; >D=@&$PKK&C& $=>7/r0Nd )$&NO@/ P %@/D )$&NO/ P %/r    r  r  zTest needs TLS 1.3 PHAc                   h   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tR tR tRtV tR# )TestPostHandshakeAuthi  c                   \         P                  \         P                  .pV EFb  p\         P                  V4      pV P	                  VP
                  R 4       RVn        V P	                  VP
                  R4       \         P                  Vn        V P	                  VP                  \         P                  4       V P	                  VP
                  R4       R Vn        V P	                  VP                  \         P                  4       V P	                  VP
                  R 4       \         P                  Vn        RVn        V P	                  VP                  \         P                  4       V P	                  VP
                  R4       EKe  	  R# rP  )	r   rH   rI   rT   r   post_handshake_authr   r   r   )r   r  rL   r<   s   &   r   test_pha_setter%TestPostHandshakeAuth.test_pha_setter  s"   ##S%<%<
	 "H..*CS44e<&*C#S44d;!//COS__c.?.?@S44d;&+C#S__c.?.?@S44e<!//CO&*C#S__c.?.?@S44d;% "r    c           	        \        4       w  rpR Vn        \        P                  Vn        R Vn        VP                  \        4       \        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       VP                  R4       V P                  VP                  R4      R4       VP                  R4       V P                  VP                  R4      R4       VP                  R4       V P                  VP                  R4      R	4       VP                  R4       V P                  VP                  R4      R4       VP                  R
4       VP                  R4      P!                  R4      pV P#                  RV4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)TFr2  r  rs  r,  ru  rr  rn  rt  rv  i   rp  zPython Software Foundation CAN)r   r  r   r   r   r   r   r:  r   r   r  r,  r3  ro   r   rf  decoder  )r   r   r   r   r2  r   	cert_texts   &      r   test_pha_required'TestPostHandshakeAuth.test_pha_required  sn   3B3D0-1*%(%6%6"-1*&&7#N5IV++FMMO<D , F FIJ		4-.
#  z:  w7
#  y9  w7
#FF4L//
;	=yIF VF F VVs%   /GD-G	9GGGG/	c                   \        4       w  rpR Vn        \        P                  Vn        R Vn        R pWBn        WAn        \        VR R7      pT;_uu_ 4        VP                  \        P                  ! 4       VRR7      ;_uu_ 4       pVP                  \        VP                  34       VP                  R4       V P                  \        R4      ;_uu_ 4        VP                  R4      pV P!                  VR4       VP                  R	4       VP                  R4       R
R
R
4       R
R
R
4       R
R
R
4       R
#   + '       g   i     L"; i  + '       g   i     L-; i  + '       g   i     R
# ; i)Tc                     \         P                  '       dC   V\        P                  8X  d,   WW#WE3p\        P
                  P                  R V: R24       R# R# R# )zTLS: r   N)r   rm   r   ALERTrk   rn   ro   )r  	directionrW   content_typemsg_typer   r  s   &&&&&& r   msg_cb>TestPostHandshakeAuth.test_pha_required_nocert.<locals>.msg_cb  sG    <?3H3H#HO

  5!34 $Ir    r2  Frc  rr  z`certificate required|EOF occurred|closed by the remote host|Connection reset by peer|Broken piper,  rn  rs  N)r   r  r   r   r   _msg_callbackr:  r   r   r  r,  r3  ro   r   re  rf  r   )r   r   r   r   r  r2  r   r   s   &       r   test_pha_required_nocert.TestPostHandshakeAuth.test_pha_required_nocert  s'   3B3D0-1*%(%6%6"-1*	5
 (.$'-$#N4HV++FMMO<DAF , H HKL		4-. ++$  66$<D$$T73 GGJ' FF4L!H V H H VVs>   0EAE	AD8E	&E8EE	EEE/	c           	        \         P                  '       d    \        P                  P	                  R 4       \        4       w  rpRVn        \        P                  Vn	        RVn        VP                  \        4       \        P                  Vn	        \        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP!                  \"        VP$                  34       VP	                  R4       V P'                  VP)                  R4      R4       VP	                  R4       V P'                  VP)                  R4      R	4       VP	                  R4       V P'                  VP)                  R4      R
4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r   TFr2  r  rs  r,  ru  rr  rn  rt  N)r   rm   rk   rn   ro   r   r  r   r   r   r   r   r   r:  r   r   r  r,  r3  r   rf  r;  s   &     r   test_pha_optional'TestPostHandshakeAuth.test_pha_optional  sC   ???JJT"3B3D0-1*%(%6%6"-1*&&7 &)%6%6"#N5IV++FMMO<D , F FIJ		4-.
#  z:  w7
#  y9F VF F VVs%   '/F3B8F 	F3 F0+F33G	c           	     :   \         P                  '       d    \        P                  P	                  R 4       \        4       w  rpRVn        \        P                  Vn	        RVn        \        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       VP	                  R4       V P!                  VP#                  R4      R4       VP	                  R4       V P!                  VP#                  R4      R	4       VP	                  R4       V P!                  VP#                  R4      R4       R
R
R
4       R
R
R
4       R
#   + '       g   i     L; i  + '       g   i     R
# ; i)r   TFr2  r  rs  r,  ru  rr  rn  N)r   rm   rk   rn   ro   r   r  r   r   r   r:  r   r   r  r,  r3  r   rf  r;  s   &     r   test_pha_optional_nocert.TestPostHandshakeAuth.test_pha_optional_nocert3  s%   ???JJT"3B3D0-1*%(%6%6"-1*#N5IV++FMMO<D , F FIJ		4-.
#  z:  w7
#  z:F VF F VVs%   =/F	,B8E6	$F	6FF		F	c                   \        4       w  rpR Vn        \        P                  Vn        VP                  \        4       \        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       V P                  \        P                  R4      ;_uu_ 4        VP                  4        RRR4       VP!                  R4       V P#                  RVP%                  R4      4       RRR4       RRR4       R#   + '       g   i     LT; i  + '       g   i     L-; i  + '       g   i     R# ; i)	TFr2  r  z
not serverNrr  s   extension not receivedr,  )r   r  r   r   r   r   r   r:  r   r   r  r,  r3  r   r   r}  ro   r  rf  r;  s   &     r   test_pha_no_pha_client,TestPostHandshakeAuth.test_pha_no_pha_clientI  s    3B3D0-1*%(%6%6"&&7#N5IV++FMMO<D , F FIJ		4-.++CLL,GG224 H7FF V HGF F VVs=   /EA
D?	D, :D?	E,D<7D?	?E
EE#	c           	        \        4       w  rp\        P                  Vn        R Vn        VP                  \        4       \        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       VP                  R4       V P                  VP                  R4      R4       VP                  R4       V P                  VP                  R4      R4       VP                  R4       V P                  VP                  R4      R4       R	R	R	4       R	R	R	4       R	#   + '       g   i     L; i  + '       g   i     R	# ; i)
TFr2  r  rs  r,  rt  rr  rn  N)r   r   r   r   r  r   r   r:  r   r   r  r,  r3  ro   r   rf  r;  s   &     r   test_pha_no_pha_server,TestPostHandshakeAuth.test_pha_no_pha_serverY  s   3B3D0%(%6%6"-1*&&7#N5IV++FMMO<D , F FIJ		4-.
#  y9  w7
#  y9F VF F VVs%   /E"B8E	=E"EE""E3	c           
     b   \        4       w  rp\        P                  Vn        \        P                  P
                  Vn        R Vn        VP                  \        4       \        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       VP!                  R4       V P#                  RVP%                  R4      4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)TFr2  r  rr  s   WRONG_SSL_VERSIONr,  N)r   r   r   r   r   rS   rP   r  r   r   r:  r   r   r  r,  r3  ro   r  rf  r;  s   &     r   test_pha_not_tls13(TestPostHandshakeAuth.test_pha_not_tls13m  s    3B3D0%(%6%6"),)?)?&-1*&&7#N5IV++FMMO<D , F FIJ		4-.2AFF4LAF VF F VVs%   5/D$AD
	8D
DDD.	c           	     D   \         p\        P                  \        P                  4      pR Vn        VP                  \        4       RVn        \        P                  Vn	        \        P                  \        P                  4      pVP                  \        4       VP                  \        4       R Vn        \        P                  Vn	        \        VRR7      pT;_uu_ 4        VP                  \         P                   ! 4       VR7      ;_uu_ 4       pVP#                  \$        VP&                  34       VP)                  R4       V P+                  VP-                  R4      R4       VP)                  R4       V P+                  VP-                  R4      R4       VP)                  R4       V P+                  VP-                  R4      R	4       V P+                  VP/                  4       / 4       R
R
R
4       R
R
R
4       R
#   + '       g   i     L; i  + '       g   i     R
# ; i)TFr2  r  rs  r,  ru  rr  rn  rt  N)r   r   rT   rI   r  r   r   r   r   r   rH   r   r   r   r:  r   r   r  r,  r3  ro   r   rf  r  )r   r   r   r   r2  r   s   &     r   test_bpo37428_pha_cert_none1TestPostHandshakeAuth.test_bpo37428_pha_cert_none~  s    ,(?(?@-1*&&7(-%%(]]"(?(?@&&7,,Z8-1*%(%6%6"#N5IV++FMMO<D , F FIJ		4-.
#  z:  w7
#  y9  "5F VF F VVs%   "/HCG;	)H;HHH	c                   \        R R7      w  rp\        VR R7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP	                  \
        VP                  34       VP                  P                  4       pV P                  \        V4      ^4       Vw  rxVP                  P                  4       p	V P                  \        V	4      ^4       V P                  Wy^ ,          4       V P                  \        V4      \        V	^ ,          4      4       V P                  \        V4      \        V	^ ,          4      4       V P                  Wx4       V P                  \        V4      \        V4      4       V P                  \        V4      \        V4      4       V P                  VP                  4       VP                  4       4       V P!                  R\        V4      4       V P!                  R\        V4      4       VP#                  \$        P&                  4      p
VP#                  \$        P(                  4      pV P+                  V
\,        4       V P!                  RV
4       V P+                  V\.        4       V P                  \0        P3                  V
4      V4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)Fr   r2  r  zCN=localhostzCN=our-ca-serverz-----BEGIN CERTIFICATE-----N)r   r:  r   r   r  r,  r3  r  r~  r   rK   r  hashr   r  get_infor  public_bytesr   ENCODING_PEMENCODING_DERrD  rD   r  r   r1  )r   r   r   r   r2  r   vceecauvcr7  r,  s   &           r   test_internal_chain_client0TestPostHandshakeAuth.test_internal_chain_client  s   3B4
0 $N5IV++ ( ,   		4-.YY113  R!,ii446  S1-  V,  b4A<8  b4A<8##B+##DHd2h7##DHd2h7##BKKM2;;=And2h70$r(;ood&7&78ood&7&78%%c3/;SA%%c51  ,,S137 V  VVs$   /KIK	2KKKK(	c           	        \        R R7      w  rp\        VR R7      p\        \        4      ;_uu_ 4       p\        P                  VP                  4       4      pRRR4       \        \        4      ;_uu_ 4       p\        P                  VP                  4       4      pRRR4       T;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       VP                  4       p	V P                  \        V	4      ^4       V	w  rV P!                  V
\"        4       V P!                  V\"        4       V P                  XV4       V P                  XV
4       VP%                  4       pV P                  \        V4      ^4       V P!                  V^ ,          \"        4       V P                  W^ ,          4       V P'                  W4       RRR4       RRR4       R#   + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     LB; i  + '       g   i     R# ; i)Fr  r2  Nr  )r   r:  r0   r   r   r1  r1   SINGED_CERTFILE_ONLYr   r   r  r,  r3  r~  r   rK   rD  r  r  r  )r   r   r   r   r2  r3   expected_ca_certexpected_ee_certr   r  r  r  r  s   &            r   test_certificate_chain,TestPostHandshakeAuth.test_certificate_chain  s   3B4
0 $N5I*"77A  &''1"77A ( V++ ( ,   		4-.))+  R!,%%b%0%%b%0  !126  !126,,.  S1-%%c!fe4  V,##B+' V  (''  VVs<   $H 7$H-/H;DH(	.H; H	H%	(H83H;;I	c           	        \        4       w  rpVP                  \        4       \        P                  Vn        \        P                  P                  Vn        \        VR R7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       VP                  R4       VP!                  R4      pV P#                  VR4       VP                  R4       VP!                  R4      pV P#                  VR4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)Fr2  r  s   VERIFIEDCHAIN
r,  s   
s   UNVERIFIEDCHAIN
N)r   r   r   r   r   r   r   rS   rP   r:  r   r   r  r,  r3  ro   rf  r   )r   r   r   r   r2  r   ress   &      r   test_internal_chain_server0TestPostHandshakeAuth.test_internal_chain_server  s   3B3D0&&7%(%6%6"),)?)?&#N5IV++ ( ,   		4-.*+ffTl  i0,-ffTl  i0 V  VVs%   ./EB
D9	'E9E	EE	r@   N)r  r>  r?  r@  r  r  r  r  r  r  r  r  r  r  r  r  rF  rG  rH  s   @r   r  r    sL     <0J2'!R:0;,G :(B"6>#J ,D1 1r    r  keylog_filenamez0test requires OpenSSL 1.1.1 with keylog callbackc                      a  ] tR tRt o ]P
                  3R lt]R 4       t]R 4       t	]]
P                  ! ]P                  P                  R4      R 4       4       tR tR tR	 tR
tV tR# )TestSSLDebugi  c                    \        V4      ;_uu_ 4       p\        \        V4      4      uuR R R 4       #   + '       g   i     R # ; ir?   )r0   rK   r  )r   fnamer3   s   && r   keylog_linesTestSSLDebug.keylog_lines  s$    %[[AtAw< [[[s	   3A	c                   V P                  \        P                  \        P                  4       \        P                  \        P                  4      pV P                  VP                  R 4       V P                  \        P                  P                  \        P                  4      4        \        P                  Vn        T P                  TP                  \        P                  4       T P!                  \        P                  P                  \        P                  4      4       T P                  T P#                  4       ^4       R Tn        T P                  TP                  R 4       T P%                  \&        \(        34      ;_uu_ 4        \        P                  P+                  \        P                  P-                  \        P                  4      4      Tn        R R R 4       T P%                  \.        4      ;_uu_ 4        ^Tn        R R R 4       R #   \         d     \        '       d   T P                  R4       h i ; i  + '       g   i     Ll; i  + '       g   i     R # ; i)Nr  )r  r   r  r  r   rT   rI   r   r  r}  r   r   isfiler  r  r&  r  r  r   IsADirectoryErrorPermissionErrorr   abspathr   rU  s   & r   test_keylog_defaults!TestSSLDebug.test_keylog_defaults  s   	(()*:*:;nnS445,,d3	(8(89:	"+"2"2C
 	,,i.>.>?y'7'789**,a0",,d3 1?CDD"$''//	 0 01#3C E
 y))"#C *)!  	~BC	 ED
 *))s+   +H AI IH=*H= I	I$	c           	     &   V P                  \        P                  \        P                  4       \	        4       w  rp \        P                  Vn        \        TRR7      pT;_uu_ 4        TP                  \        P                  ! 4       TR7      ;_uu_ 4       pTP                  \        TP                  34       RRR4       RRR4       T P                  T P!                  4       ^4       RTn        \        P                  Tn        \        TRR7      pT;_uu_ 4        TP                  \        P                  ! 4       TR7      ;_uu_ 4       pTP                  \        TP                  34       RRR4       RRR4       T P#                  T P!                  4       ^4       \        P                  Tn        \        P                  Tn        \        TRR7      pT;_uu_ 4        TP                  \        P                  ! 4       TR7      ;_uu_ 4       pTP                  \        TP                  34       RRR4       RRR4       T P#                  T P!                  4       ^4       RTn        RTn        R#   \         d     \        '       d   T P                  R 4       h i ; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL`; i  + '       g   i     ELl; i  + '       g   i     L; i  + '       g   i     L; i)r  Fr2  r  N)r  r   r  r  r   r  r  r  r&  r:  r   r   r  r,  r3  r   r  r   r;  s   &     r   test_keylog_filename!TestSSLDebug.test_keylog_filename  sR   	(()*:*:;3B3D0	-6-=-=N* $N5IV++FMMO<D , F FIJ		4-.F 
 	**,a0)-&)2)9)9&#N5IV++FMMO<D , F FIJ		4-.F  	 1 1 3R8)2)9)9&)2)9)9&#N5IV++FMMO<D , F FIJ		4-.F  	 1 1 3R8)-&)-&A  	~BC	F F F VVF F F VVF F Vs}   I0 )/J1"J	:J1/K"K	.K/L "K-	0L 0JJJ.(	J11K	K	KK*	-K=8L  L	z.test is not compatible with ignore_environmentc                   V P                  \        P                  \        P                  4       \        P
                  P                  P                  \        P                  4      ;_uu_ 4        \        P                  \        P                  R &   V P                  \        P                  R ,          \        P                  4       \        P                  \        P                  4      pV P                  VP                  R4        \        P                  4       pT P                  TP                  \        P                  4       \        P'                  4       pT P                  TP                  \        P                  4       RRR4       R#   \          d     \"        '       d   T P%                  R4       h i ; i  + '       g   i     R# ; i)SSLKEYLOGFILENr  )r  r   r  r  r[   mockrP  dictr   environr   r   rT   rI   r  r@  r  r  r&  rG  rU  s   & r   test_keylog_envTestSSLDebug.test_keylog_envH  s/    		(()*:*:;]]  %%bjj11*3*:*:BJJ'RZZ8):J:JK..!8!89CS00$7002
 S00)2B2BC,,.CS00)2B2BC! 21   !>MM"FG 211s,   .BF8FA(F8F5"F55F88G		c                4   \        4       w  rpR  pV P                  VP                  R4       WAn        V P                  VP                  V4       V P                  \        4      ;_uu_ 4        \        4       Vn        RRR4       R#   + '       g   i     R# ; i)c                     R # r?   r@   r  r  rW   r  r  r   s   &&&&&&r   r  .TestSSLDebug.test_msg_callback.<locals>.msg_cbb  r  r    N)r   r   r  r   r   r  )r   r   r   r   r  s   &    r   test_msg_callbackTestSSLDebug.test_msg_callback_  sn    3B3D0	 	n22D9'-$n22F;y))+18N( *)))s   ,BB	c           	       a a \        4       w  rp\        P                  P                  Vn        . oVV 3R  lpWAn        \        VRR7      pT;_uu_ 4        VP                  \        P                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       RRR4       RRR4       S P                  R\        P                  \        P                  \        P                   3S4       S P                  R\        P                  \        P"                  \        P"                  3S4       R#   + '       g   i     L; i  + '       g   i     L; i)c                    < SP                  V \        P                  4       SP                  V\        4       SP	                  VR R04       SP                  WW434       R# )r1   ro   N)rD  r   r   r  r  r  )r  r  rW   r  r  r   r  r   s   &&&&&&r   r  4TestSSLDebug.test_msg_callback_tls12.<locals>.msg_cbq  sK    !!$6!!$.MM)fg%67JJ	LCDr    Fr2  r  Nr1   ro   )r   r   r   rS   rP   r  r:  r   r   r  r,  r3  r  r   	HANDSHAKEr   SERVER_KEY_EXCHANGECHANGE_CIPHER_SPEC)r   r   r   r   r  r2  r   r  s   f      @r   test_msg_callback_tls12$TestSSLDebug.test_msg_callback_tls12k  s   3B3D0),)?)?&	E (.$#N5IV++FMMO<D , F FIJ		4-.F 
 	Z'')B)B002	

 	j((/*L*L//1	
F F Vs$   /E"D8	&E8EEE	c           	       a \        4       w  rp\        4       ^,          oR pV3R lpWBn        WRn        \        VRR7      pT;_uu_ 4        VP	                  \
        P
                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       RRR4       VP	                  \
        P
                  ! 4       VR7      ;_uu_ 4       pVP                  \        VP                  34       RRR4       RRR4       R#   + '       g   i     Lr; i  + '       g   i     L-; i  + '       g   i     R# ; i)rc  c                     R # r?   r@   r!  s   &&&&&&r   r  @TestSSLDebug.test_msg_callback_deadlock_bpo43577.<locals>.msg_cb  r  r    c                    < SV n         R # r?   r9  )r   r  r<   server_context2s   &&&r   sni_cb@TestSSLDebug.test_msg_callback_deadlock_bpo43577.<locals>.sni_cb  s
    *DLr    Fr2  r  N)	r   r  sni_callbackr:  r   r   r  r,  r3  )	r   r   r   r   r  r2  r2  r   r1  s	   &       @r   #test_msg_callback_deadlock_bpo435770TestSSLDebug.test_msg_callback_deadlock_bpo43577  s    3B3D0)+A.		+ (.$&,##N5IV++FMMO<D , F FIJ		4-.F  ++FMMO<D , F FIJ		4-.F	 VF FF F	 VVs<   /D-;"D	6D-"D	5D-DD-D*%D--D>	r@   N)r  r>  r?  r@  r   r  r  requires_keylogr  r  r[   re  rk   r#  ignore_environmentr  r#  r+  r5  rF  rG  rH  s   @r   r	  r	    s     !*!1!1   $ $6 &. &.P __SYY11EGDG D(
4
>/ /r    r	  c           	          V P                  \        P                  \        P                  \        P
                  ! R ^^ 4      4       R# )iiN)
setsockoptr   
SOL_SOCKET	SO_LINGERstructpackr   s   &r   )set_socket_so_linger_on_with_zero_timeoutrA    s+    OOF%%v'7'7T1a9PQr    c                   f   a  ] tR tRt o Rt ! R R]P                  4      tR tR t	R t
R tR	tV tR
# )TestPreHandshakeClosei  zQVerify behavior of close sockets with received data before to the handshake.
    c                   X   a a ] tR tRt oRR/V 3R lltR tR tV 3R ltR tR	t	Vt
V ;t# )
6TestPreHandshakeClose.SingleConnectionTestServerThreadi  rx  Nc                  < W n         R V n        RV n        RV n        RV n        Vf   \
        P                  V n        MW0n        \        SV `%  VR7       R# )r    Nr   )
call_after_acceptreceived_data
wrap_errorrl  r3  r   r  rx  superrU  )r   r   rG  rx  r  s   &$$$r   rU  ?TestPreHandshakeClose.SingleConnectionTestServerThread.__init__  sM    %6"!$D"DO DMDI&44&G$'r    c                &    V P                  4        V # r?   )r  r   s   &r   r  @TestPreHandshakeClose.SingleConnectionTestServerThread.__enter__  s    JJLKr    c                     V P                   '       d   V P                   P                  4        T P                  4        R T n        R #   \         d     L&i ; ir?   )rl  r  re  r   rI  r  s   &*r   r  ?TestPreHandshakeClose.SingleConnectionTestServerThread.__exit__  sF    ===MM'') IIK"DO  s   A A AAc                N  < \         P                  \         P                  P                  4      V n        \         P
                  V P                  n        V P                  P                  \        R 7       V P                  P                  \        \        R7       \        P                  ! 4       V n        \        P                  ! V P                  4      V n        V P                  P!                  V P"                  4       V P                  P%                  ^4       \&        SV `Q  4        R# )r  r  N)r   r@  r   r  ssl_ctxr   r   r   r  r   r  r   rl  r   r*  r3  rv  rx  r  rJ  r  )r   r  s   &r   r  <TestPreHandshakeClose.SingleConnectionTestServerThread.start  s    55ckk6M6MNDL'*'8'8DLL$LL..h.?LL(((G(L"MMODM%//>DIMM$$T\\2MM  #GMOr    c                f    V P                   P                  4       w  r T P                   P                  4        T;_uu_ 4        T P	                  T4      '       d    R R R 4       R #  T P
                  P                  TRR7      p TP                  R4      T n        R R R 4       R #   \         d     T P                   P                  4        R # i ; i  T P                   P                  4        i ; i  \         d     Lbi ; i  \         d   pY@n
         R p?L|R p?ii ; i  + '       g   i     R # ; i)NTrY    )rl  r  r  r  rG  rQ  r   rf  rH  re  rI  )r   r  address
tls_socketr  s   &    r   r  :TestPreHandshakeClose.SingleConnectionTestServerThread.run  s    & $ 4 4 6g
 ##%))$// !%!9!9$D!9!QJ-7__S-A*    ##%	 ##% #   *&)OO* sq   B% D'DC0%C0C CC C-0C>;D=C>>DDDDDDD0	)rG  rl  r3  rH  rQ  rx  rI  )r  r>  r?  r@  rU  r  r  r  r  rF  rG  __classcell__)r  rI  s   @@r    SingleConnectionTestServerThreadrE    s*     
	(t 
	(		#			 	r    rY  c           
        \         P                  R9   d   R# \        V\        4      '       gv   \        V\        4      '       d    VP
                  \
        P                  8X  gA   \        P                  ! R\        \        VRR4      4      \        P                  4      '       d,    V P                  R\         P                   RV: 24       RpR# R#   Rpi ; i)linuxNzwrong.version.numberrs  rX  z!Could not recreate conditions on z: err=)r[  android)rk   rD  rC   r^  re  r-  EINVALr  searchrD   rF   r  r&  r  s   &&r   "non_linux_skip_if_other_okay_error8TestPreHandshakeClose.non_linux_skip_if_other_okay_error  s    <<//s011W%%#))u||*CII,c'#x2L.MrttTT A#,, P'"%) *  U s   $&C Cc                Z  aa \         P                  ! 4       o\         P                  ! 4       oVV3R  lpV P                  VRR7      pV P                  V4       \        P                  ! 4       ;_uu_ 4       pVP                  VP                  P                  4       4       \        V4       VP                  R4       SP                  4        VP                  R4       VP                  4        RRR4       SP                  4        VP                  4        VP                  pRVn         V P!                  RVP"                  4       V P%                  V\&        4       V P)                  V4       V P%                  V\*        P,                  4       V P/                  RVP0                  ^,          4       V P/                  RVP2                  4       V P5                  ^ VP0                  ^ ,          4       V P7                  VP8                  RR	7       RpRpR#   + '       g   i     EL-; i  RpRpi ; i)
c                    < SP                  4        SP                  \        P                  4      '       g   \	        R 4      hR# )z+wrap_socket event never set, test may fail.F)r  r  r   r  r  )unusedready_for_server_wrap_socketserver_accept_calleds   &r   rG  PTestPreHandshakeClose.test_preauth_data_to_tls_server.<locals>.call_after_accept  s5     $$&/44W5J5JKK"#PQQr    preauth_data_to_tls_serverrG  r   Fs   DELETE /data HTTP/1.0

Nr    before TLS handshake with dataattr must existr  )rT  r  rY  r  r   r  rl  r  rA  rx  r  rj  r  r  r   rI  r   rH  rD  re  r_  r   r   r  r]   rs  r  r  rq  )r   rG  r2  r  rI  rd  re  s   &    @@r   test_preauth_data_to_tls_server5TestPreHandshakeClose.test_preauth_data_to_tls_server  s   (0'0'8$	 66"31 7 3 	&!]]__NN6??66895f=u% %%'KK89LLN  	%((*&&
 	S&"6"67!!*g633J?!!*cll;MM:JOOA<NOMM:J<M<MN:??1#56j006GH JF7 __4 JFs   5A7H(C"H$ H!	$H*c           	       a	a
 \         P                  ! 4       o
\         P                  ! 4       o	V	V
3R  lpV P                  VRR7      pV P                  V4       \	        VP
                  4       \        P                  ! 4       ;_uu_ 4       pVP                  VP
                  P                  4       4       S
P                  4        S	P                  \        P                  4      '       g   V P                  R4       \        P                  4       p VP!                  VRR7      pRpVP#                  R4      pVP%                  4        RRR4       VP)                  4         V P+                  RX4       V P-                  X\&        4       V P/                  V4       V P-                  V\        P0                  4       V P3                  R	VP4                  ^,          4       V P3                  R	VP6                  4       V P9                  ^ VP4                  ^ ,          4       V P;                  VP<                  R
R7       \>        P@                  ! V 4      ;_uu_ 4        RpRRR4       RpR#   \&         d   pTpRp Rp?EL3Rp?ii ; i  + '       g   i     ELD; i  + '       g   i     LE; i  \>        P@                  ! T 4      ;_uu_ 4        RpRRR4       Rpi   + '       g   i     Rpi ; i; i)c                    < SP                  \        P                  4      '       g   \        R 4       \	        V 4       V P                  R4       V P                  4        SP                  4        R# )z ERROR: test client took too longsW   HTTP/1.0 307 Temporary Redirect
Location: https://example.com/someone-elses-server

T)r  r   r  r  rA  rj  r  r  )conn_to_client$client_can_continue_with_wrap_socket$server_can_continue_with_wrap_sockets   &r   rG  PTestPreHandshakeClose.test_preauth_data_to_tls_client.<locals>.call_after_accept.  s]    7<<W=R=RSS89 6nE   "0446r    preauth_data_to_tls_clientrh  ztest server took too longr#   r  NrT  r    ri  rj  r  )!rT  r  rY  r  rA  rl  r   r  r  r  r  r   r  r4  r   r@  r   rf  r  re  r   r   rD  r_  r   r  r]   rs  r  r  rq  r
   rI  )r   rG  r2  r  rQ  
tls_clientrI  rH  r  rp  rq  s   &        @@r   test_preauth_data_to_tls_client5TestPreHandshakeClose.test_preauth_data_to_tls_client*  s8   /8/@,/8/@,	 66"31 7 3 	&!1&//B]]__NN6??668904467<<W=R=RSS		56002G	#$00 1 =
 "
 * 4  "! $ 		S-0!!*g633J?!!*cll;MM:JOOA<NOMM:J<M<MN:??1#56j006GH !::4@@!
 AF-  $ 
 #$ __< A@::4@@!
 AF A@Fsh   
BJ I#"#J CJ' J#I=.I82J 8I==J  J	J$	'K)K		K)K&
K)c           
       a \         P                  ! 4       o ! V3R  lR\        P                  P                  4      pV3R lpRpV P                  VRVR7      pV P                  V4       \        VP                  4       V! VP                  P                  4       ^ ,          VP                  \        P                  4       VR7      p\        P                  ! V 4      ;_uu_ 4        V P                  \         4      ;_uu_ 4        VP#                  RRR	R
/R7       VP%                  4       pRRR4       RRR4       VP'                  4        R#   + '       g   i     L*; i  + '       g   i     L5; i)c                   .   <a  ] tR tRt o V3R ltRtV tR# )eTestPreHandshakeClose.test_https_client_non_tls_response_ignored.<locals>.SynchronizedHTTPSConnectionih  c                z  < \         P                  P                  P                  V 4       SP	                  \
        P                  4      '       g6   \
        P                  '       d    \        P                  P                  R 4       V P                  P                  V P                  V P                  R7      V n        R# )z"server_responding event never set.r  N)httpr  HTTPConnectionr  r  r   r  rm   rk   rn   ro   _contextr   r   r  )r   server_respondings   &r   r  mTestPreHandshakeClose.test_https_client_non_tls_response_ignored.<locals>.SynchronizedHTTPSConnection.connecti  sy     **2248 )--g.C.CDDJJ$$%IJ MM55		499 6 >	r    r@  N)r  r>  r?  r@  r  rF  rG  )rI  r~  s   @r   SynchronizedHTTPSConnectionry  h  s     	> 	>r    r  c                    < \        V 4       V P                  R 4       V P                  4        SP                  4        R# )s!   HTTP/1.0 402 Payment Required

T)rA  rj  r  r  )ro  r~  s   &r   rG  [TestPreHandshakeClose.test_https_client_non_tls_response_ignored.<locals>.call_after_acceptt  s;    5nE   "!!#r    g       @non_tls_http_RST_responder)rG  r   rx  )r3  r   rx  HEADz/testHostr#   )headersN)rT  r  r{  r  HTTPSConnectionrY  r  rA  rl  r  r3  r   r@  r
   rI  r   re  r  getresponser   )r   r  rG  rx  r2  
connectionresponser~  s   &      @r   *test_https_client_non_tls_response_ignored@TestPreHandshakeClose.test_https_client_non_tls_response_ignorede  s   %OO-
	>$++*E*E 
	>	 66"31 7 ! 	&!1&//B0++-a0[[224	

 66t<<!!'**vw8MN!--/H + =
 		 +* =<s$   $E'E	)EEEE.	r@   N)r  r>  r?  r@  r4  rT  r   rY  r_  rk  ru  r  rF  rG  rH  s   @r   rC  rC    s8     :9+;+; :x2*X9v3 3r    rC  c                   \   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tRtV tR# )TestEnumerationsi  c                n     ! R  R\         P                  4      p\         P                  ! V\        4       R# )c                       ] tR tRt]P
                  t]P                  t]P                  t
]P                  t]P                  t]P                  t]P"                  tRtR# );TestEnumerations.test_tlsversion.<locals>.CheckedTLSVersioni  r@   N)r  r>  r?  r@  r   PROTO_MINIMUM_SUPPORTEDrU   PROTO_SSLv3r  PROTO_TLSv1r  PROTO_TLSv1_1r8   PROTO_TLSv1_2rS   PROTO_TLSv1_3r  PROTO_MAXIMUM_SUPPORTEDrV   rF  r@   r    r   CheckedTLSVersionr    sQ     $ < <$$E$$E((G((G((G $ < <r    r  N)enumIntEnum_test_simple_enumr   )r   r  s   & r   test_tlsversion TestEnumerations.test_tlsversion  s%    	= 	= 	0*=r    c                n     ! R  R\         P                  4      p\         P                  ! V\        4       R# )c                   2    ] tR tRtRt^t^t^t^tRt	Rt
RtR# )DTestEnumerations.test_tlscontenttype.<locals>.Checked_TLSContentTypei  z8Content types (record layer)

See RFC 8446, section B.1
r>    r@   N)r  r>  r?  r@  r4  r*  r  r(  APPLICATION_DATAHEADERINNER_CONTENT_TYPErF  r@   r    r   Checked_TLSContentTyper    s*     "$EI!F!&r    r  N)r  r  r  r   )r   r  s   & r   test_tlscontenttype$TestEnumerations.test_tlscontenttype  s%    	'T\\ 	' 	5Gr    c                n     ! R  R\         P                  4      p\         P                  ! V\        4       R# )c                       ] tR tRtRt^ t^
t^t^t^t	^t
^(t^)t^*t^+t^,t^-t^.t^/t^0t^1t^2t^3t^<t^Ft^Gt^Pt^Vt^Zt^dt^mt^nt^ot ^pt!^qt"^rt#^st$^tt%^xt&Rt'R# )@TestEnumerations.test_tlsalerttype.<locals>.Checked_TLSAlertTypei  zIAlert types for TLSContentType.ALERT messages

See RFC 8466, section B.2
r@   N)(r  r>  r?  r@  r4  CLOSE_NOTIFYUNEXPECTED_MESSAGEBAD_RECORD_MACDECRYPTION_FAILEDRECORD_OVERFLOWDECOMPRESSION_FAILUREHANDSHAKE_FAILURENO_CERTIFICATEBAD_CERTIFICATEUNSUPPORTED_CERTIFICATECERTIFICATE_REVOKEDCERTIFICATE_EXPIREDCERTIFICATE_UNKNOWNILLEGAL_PARAMETER
UNKNOWN_CAACCESS_DENIEDDECODE_ERRORDECRYPT_ERROREXPORT_RESTRICTIONPROTOCOL_VERSIONINSUFFICIENT_SECURITYINTERNAL_ERRORINAPPROPRIATE_FALLBACKUSER_CANCELEDNO_RENEGOTIATIONMISSING_EXTENSIONUNSUPPORTED_EXTENSIONCERTIFICATE_UNOBTAINABLEUNRECOGNIZED_NAMEBAD_CERTIFICATE_STATUS_RESPONSEBAD_CERTIFICATE_HASH_VALUEUNKNOWN_PSK_IDENTITYCERTIFICATE_REQUIREDNO_APPLICATION_PROTOCOLrF  r@   r    r   Checked_TLSAlertTyper    s     L!#N " O$&! "N O&(#"$"$"$ "JMLM!#!$&!N%'"M" #$'!'*$ #.1+),&#& #& &)#r    r  N)r  r  r  r   )r   r  s   & r   test_tlsalerttype"TestEnumerations.test_tlsalerttype  s&    &	*4<< &	*N 	3]Cr    c                n     ! R  R\         P                  4      p\         P                  ! V\        4       R# )c                   r    ] tR tRtRt^ t^t^t^t^t	^t
^t^t^t^t^t^t^t^t^t^t^t^t^t^Ct^tRtRtR# )DTestEnumerations.test_tlsmessagetype.<locals>.Checked_TLSMessageTypei  z>Message types (handshake protocol)

See RFC 8446, section B.3
r  r@   N)r  r>  r?  r@  r4  HELLO_REQUESTCLIENT_HELLOSERVER_HELLOHELLO_VERIFY_REQUESTNEWSESSION_TICKETEND_OF_EARLY_DATAHELLO_RETRY_REQUESTENCRYPTED_EXTENSIONSCERTIFICATEr)  CERTIFICATE_REQUESTSERVER_DONECERTIFICATE_VERIFYCLIENT_KEY_EXCHANGEFINISHEDCERTIFICATE_URLCERTIFICATE_STATUSSUPPLEMENTAL_DATA
KEY_UPDATE
NEXT_PROTOMESSAGE_HASHr*  rF  r@   r    r   Checked_TLSMessageTyper    s     MLL#$  ! !"##$ K"$"$K!#"$H O!# "JJL!'r    r  N)r  r  r  r   )r   r  s   & r   test_tlsmessagetype$TestEnumerations.test_tlsmessagetype  s%    	(T\\ 	(6 	5Gr    c                    \         P                  ! \         P                  R RR \        P                  R7      pVP
                  Vn        \         P                  ! V\        P                  4       R# )
_SSLMethodr   c                 >    V P                  R 4      ;'       d    V R8g  # )rB   r   rE   r   s   &r   r  1TestEnumerations.test_sslmethod.<locals>.<lambda>  s    T__[9WWdFW>WWr    sourceN)	r  _old_convert_r  r   r   rG   r   r  r  )r   Checked_SSLMethods   & r   test_sslmethodTestEnumerations.test_sslmethod  sN     ..lEWxx ->,J,J)0#..Ar    c                    \         P                  ! \         P                  R RR \        P                  R7      p\         P
                  ! V\        P                  4       R# )Optionsr   c                 $    V P                  R 4      # )r   r  r   s   &r   r  /TestEnumerations.test_options.<locals>.<lambda>  s    T__U3r    r  N)r  r  IntFlagr   r   r  r  )r   CheckedOptionss   & r   r   TestEnumerations.test_options	  s=    ++i3xx
 	~s{{;r    c                    \         P                  ! \         P                  R RR \        P                  R7      p\         P
                  ! V\        P                  4       R# )AlertDescriptionr   c                 $    V P                  R 4      # )ALERT_DESCRIPTION_r  r   s   &r   r  8TestEnumerations.test_alertdescription.<locals>.<lambda>  s    T__-ABr    r  N)r  r  r  r   r   r  r  )r   CheckedAlertDescriptions   & r   test_alertdescription&TestEnumerations.test_alertdescription  sB    "&"4"40%Bxx#
 	68L8LMr    c                    \         P                  ! \         P                  R RR \        P                  R7      p\         P
                  ! V\        P                  4       R# )SSLErrorNumberr   c                 $    V P                  R 4      # )
SSL_ERROR_r  r   s   &r   r  6TestEnumerations.test_sslerrornumber.<locals>.<lambda>  s    T__\:r    r  N)r  r  r  r   r   r  r  )r   Checked_SSLErrorNumbers   & r   test_sslerrornumber$TestEnumerations.test_sslerrornumber  sB    !%!3!3.:xx"
 	5s7I7IJr    c                    \         P                  ! \         P                  R RR \        P                  R7      p\         P
                  ! V\        P                  4       R# )VerifyFlagsr   c                 $    V P                  R 4      # )VERIFY_r  r   s   &r   r  3TestEnumerations.test_verifyflags.<locals>.<lambda>$  s    T__Y7r    r  N)r  r  r  r   r   r  r  )r   CheckedVerifyFlagss   & r   test_verifyflags!TestEnumerations.test_verifyflags!  s?    !//mU7xx
 	13??Cr    c                    \         P                  ! \         P                  R RR \        P                  R7      p\         P
                  ! V\        P                  4       R# )
VerifyModer   c                 $    V P                  R 4      # )CERT_r  r   s   &r   r  2TestEnumerations.test_verifymode.<locals>.<lambda>,  s    T__W5r    r  N)r  r  r  r   r   r  r  )r   CheckedVerifyModes   & r   test_verifymode TestEnumerations.test_verifymode)  s?     ..lE5xx
 	0#..Ar    r@   N)r  r>  r?  r@  r  r  r  r  r  r   r  r  r  r  rF  rG  rH  s   @r   r  r    sF     	>H(DTH<B<NKDB Br    r  c                  &   \         P                  '       Ed'   R \        P                  R\        P                  /p V P                  4        F0  w  rV! 4       pV'       g   K  V^ ,          '       g   K'  V: RV: 2p M 	  \        \        P                  ! 4       4      p\        R\        P                  : R\        P                  : 24       \        RV,          4       \        R\        P                  ,          4       \        R\        P                  ,          4        \        R\        P                  ,          4       \        \         \"        \$        \&        \(        \*        \,        \.        \0        \2        \4        3 FE  p\6        P8                  P;                  V4      '       d   K*  \         P<                  ! RV,          4      h	  \>        P@                  ! 4       p\B        PD                  ! \>        PF                  .VO5!   R	#   \         d     Li ; i)
MacWindowsrh   ztest_ssl: testing with z          under %sz          HAS_SNI = %rz          OP_ALL = 0x%8xz          OP_NO_TLSv1_1 = 0x%8xzCan't read certificate file %rN)$r   rm   rD  mac_ver	win32_veritemsr   r  r   rC  rB  r   rx  r   r  r   r  r  r  r  r  r   r   r   r  BADKEYr  r   r   exists
TestFailedr	   threading_setupr[   addModuleCleanupthreading_cleanup)platsr   r_   platfilenamethread_infos         r   setUpModuler-  2  sp   8##x))
  ++-JD6DtQ"&-	 ( ))+,D  #":":< 	="T)*&45(3::56	3c6G6GGH
 	.'>=):	$
 ww~~h''$$%E%PQQ$ #224K.@@O;O  		s    H HH__main__)r  r   r   ))rz  r  )r|  r  )r}  r8   r?   )r+  TFNN)Nr   r   )rk   r[   unittest.mockastr   rT  r   rG  r   test.supportr   r   r   r	   r
   r   r  r  r   r  r>  rt   r  r   http.clientr{  r   r-  r   urllib.requestr  ri   rZ  rD  	sysconfigrb   
contextlibr   r  ImportErrorimport_moduler   r   r   r   r   r   r   rf  r  rr  _PROTOCOL_NAMESrM  r,  rB  rR   get_config_varr   r  r   verrF   r  r   r   fsencoder  r  r  r  r  r  r  r  r  r  r  r0  r0   r  r1   r   r8  r   r  r   r   r   r   rG  rF  rO  rN  rM  r   r+  rY  r   r   r;  r  r  r  r#  r   r  r	  r  r  r(   r)   r*   r+   r,   r4   r=   rM   	lru_cacherJ   rf   rr   rz   ignore_warningsr  rd  r   r   r   r   r   TestCaser   rK  rh  r  r  r  rE  r7  r  r  test.ssl_serversrK  r:  r  r  r  r  r  rB  HAS_PHAr  r7   rT   
HAS_KEYLOGr7  r	  rA  rC  r  r-  r  mainr@   r    r   <module>rC     sA         & " & ) ( !  	      	  	          "
 !!%(  T T!!==cllg&=3&&'	++y8 "112JK  JE3
U#cnnc* &)E"F ]#X&^$
M
"X&G$34 23 	8	{{6"Hl3(L1	)+
,-- -M . $
% N+ - & 	),
-..$'		4 / ^, *  01 . 
 &&DE %2 " 9:  x.
}%
&k"	*n%	
M
"01	<	 k"	+, 56 	>	"{{6" C!4a8 3 2A6 S"6: %c+H!L $S*FJ  ;;34* ! !H". %44 
/"}}/7;/!/,0/:>/,   / 4 4DK	1x(( K	1\\ 8$$ \ ~9DH%% 9Dx@3X&& @3F.X&& .`y<H-- y<x 	9%LX&& L &L4	Z	R /a)) aF	t)) tl.`KG\P/H%% P/f6 
_Y/??CKK-/v1H-- v1/v1r	 S^^%67
%%BDa/8$$ a/HRsH-- slTBx(( TBn PF zMMO ai  F2  4 .-- /..s<   V +V5V V4	VVVV V1	4W	