ó
ŒwÛjc           @   sø  d  d l  Z  d  d l Z d  d l m Z d  d l m Z d  d l Z d  d l Z d  d l	 Z	 d  d l
 Z
 d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z e j d ƒ Z e e j ƒ Z e j Z e j j  d ƒ Z! e! o]e j" d d d f k Z# d	 „  Z$ e$ d
 ƒ Z% e% j& e  j' ƒ  ƒ Z( e$ d ƒ Z) e$ d ƒ Z* e) j& e  j' ƒ  ƒ Z+ e* j& e  j' ƒ  ƒ Z, e$ d ƒ Z- e$ d ƒ Z. d Z/ e$ d ƒ Z0 e0 j& e  j' ƒ  ƒ Z1 e$ d d ƒ Z2 e$ d d ƒ Z3 e$ d ƒ Z4 e$ d ƒ Z5 e$ d ƒ Z6 e$ d ƒ Z7 e$ d ƒ Z8 d Z9 e$ d ƒ Z: e$ d ƒ Z; e$ d ƒ Z< e$ d ƒ Z= e$ d ƒ Z> e$ d ƒ Z? e$ d ƒ Z@ e$ d  ƒ ZA e$ d! ƒ ZB eB j& e  j' ƒ  ƒ ZC eD e d" d ƒ ZE eD e d# d ƒ ZF eD e d$ d ƒ ZG eD e d% d ƒ ZH eD e d& d ƒ ZI d' „  ZJ d( e jK f d) „  ƒ  YZL d* „  ZM d+ „  ZN d, „  ZO d- „  ZP d. „  ZQ d/ „  ZR d0 „  ZS e jT e jU d1 ƒ ZV d2 e jK f d3 „  ƒ  YZW d4 e jK f d5 „  ƒ  YZX d6 e jK f d7 „  ƒ  YZY d8 e jK f d9 „  ƒ  YZZ y d  d l[ Z[ Wn e\ k
 rIe] Z^ n‰ Xe_ Z^ d  d: l` ma Za d; e[ jb f d< „  ƒ  YZc d= e[ jb f d> „  ƒ  YZd d? e_ e] ee d@ „ Zf ee d d dA „ Zg dB e jK f dC „  ƒ  YZh e] dD „ Zi ej dE k rôei ƒ  n  d S(F   iÿÿÿÿN(   t   test_support(   t   assert_python_ok(   t   closingt   sslt   LibreSSLi   i    c          G   s   t  j j t  j j t ƒ |  Œ S(   N(   t   ost   patht   joint   dirnamet   __file__(   t   name(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt	   data_file"   s    s   keycert.pems   ssl_cert.pems   ssl_key.pems   keycert.passwd.pems   ssl_key.passwd.pemt   somepasst   capaths
   4e1295a3.0s
   5ed36f99.0s   revocation.crls   keycert3.pems   keycert4.pems   pycacert.pems   allsans.pems   self-signed.pythontest.nets   selfsigned_pythontestdotnet.pems   nullcert.pems   badcert.pems   XXXnonexisting.pems
   badkey.pems	   nokia.pems   nullbytecert.pems   talos-2019-0758.pems   ffdh3072.pemt   OP_NO_COMPRESSIONt   OP_SINGLE_DH_USEt   OP_SINGLE_ECDH_USEt   OP_CIPHER_SERVER_PREFERENCEt   OP_ENABLE_MIDDLEBOX_COMPATc         C   sB   d j  t j t j ƒ  Œ  ƒ } t j r> t j j |  | ƒ n  d  S(   Nt    (	   R   t	   tracebackt   format_exceptiont   syst   exc_infot   supportt   verboset   stdoutt   write(   t   prefixt
   exc_format(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   handle_errorY   s    	t
   BasicTestsc           B   s   e  Z d  „  Z RS(   c         C   s—   y t  j t j t j ƒ ƒ Wn( t k
 rG } | j d k rA qH ‚  n Xy  t  j t j t j ƒ j ƒ Wn( t k
 r’ } | j d k rŒ q“ ‚  n Xd  S(   Ni    (   R   t   sslwrap_simplet   sockett   AF_INETt   IOErrort   errnot   _sock(   t   selft   e(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_sslwrap_simplea   s     (   t   __name__t
   __module__R(   (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR   _   s   c           C   s   t  j d k S(   Ni    i	   i   i   i   (   i    i	   i   i   i   (   R   t   _OPENSSL_API_VERSION(    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   can_clear_optionss   s    c           C   s   t  j d k S(   Ni    i	   i   i   i   (   i    i	   i   i   i   (   R   t   OPENSSL_VERSION_INFO(    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   no_sslv2_implies_sslv3_hellow   s    c           C   s   t  j d k S(   Ni    i	   i   i   (   i    i	   i   i    i   (   R   R-   (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   have_verify_flags{   s    c           C   s.   t  j r& t  j ƒ  j d k r& t  j St  j S(   Ni    (   t   timet   daylightt	   localtimet   tm_isdstt   altzonet   timezone(    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt
   utc_offset   s    c         C   s{   t  j d k rw d } t j j |  | ƒ } | j d d ƒ } | j | ƒ }  |  d d k rw |  d  d	 |  d
 }  qw n  |  S(   Ni    i	   i   i   s   %b %d %H:%M:%S %Y GMTt   secondi   t   0R   i   (   i    i	   i   i	   i   (   R   R+   t   datetimet   strptimet   replacet   strftime(   t	   cert_timet   fmtt   dt(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   asn1time…   s    c            s9   t  t d ƒ r1 t j ˆ  ƒ ‡  f d †  ƒ } | Sˆ  Sd  S(   Nt   PROTOCOL_SSLv2c             sk   y t  j t  j ƒ WnG t  j k
 r] t  j d	 k r^ t j ƒ  d
 k r^ t j d ƒ ‚ q^ n Xˆ  |  | Ž  S(   Ni    i	   i   i   t   debians   squeeze/sidt    s'   Patched Ubuntu OpenSSL breaks behaviour(   i    i	   i   i   i   (   RB   s   squeeze/sidRC   (	   R   t
   SSLContextRA   t   SSLErrorR-   t   platformt   linux_distributiont   unittestt   SkipTest(   t   argst   kwargs(   t   func(    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   f–   s    (   t   hasattrR   t	   functoolst   wraps(   RL   RM   (    (   RL   sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   skip_if_broken_ubuntu_ssl”   s    	c            s"   t  j ˆ  ƒ ‡  f d †  ƒ } | S(   sy  Skip a test if the OpenSSL config MinProtocol is > TLSv1.
    OS distros with an /etc/ssl/openssl.cnf and MinProtocol set often do so to
    require TLSv1.2 or higher (Debian Buster).  Some of our tests for older
    protocol versions will fail under such a config.
    Alternative workaround: Run this test in a process with
    OPENSSL_CONF=/dev/null in the environment.
    c       	      sã   t  j j d d ƒ } y t | d ƒ �j } x` | D]X } t j d | ƒ } | r1 | j d ƒ } | d k r‰ t j d | | f ƒ ‚ q‰ q1 q1 WWd  QXWn? t	 t
 f k
 rÕ } t j rÖ t j j d | | f ƒ qÖ n Xˆ  |  | Ž  S(	   Nt   OPENSSL_CONFs   /etc/ssl/openssl.cnft   rs   MinProtocol\s*=\s*(TLSv\d+\S*)i   t   TLSv1s)   %s has MinProtocol = %s which is > TLSv1.s(   
 Could not scan %s for MinProtocol: %s
(   R   t   environt   gett   opent   ret   matcht   groupRH   RI   t   EnvironmentErrort   UnicodeDecodeErrorR   R   R   R   R   (   RJ   RK   t   openssl_cnft   configt   lineRY   t   tls_vert   err(   RL   (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRM   «   s     $	(   RO   RP   (   RL   RM   (    (   RL   sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt'   skip_if_openssl_cnf_minprotocol_gt_tls1£   s    s    SNI support needed for this testt   BasicSocketTestsc           B   s   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 e
 j d „  ƒ Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e j d e j k d ƒ d „  ƒ Z d „  Z e j e j d k d ƒ d „  ƒ Z e j e j d k d ƒ d „  ƒ Z  d „  Z! d „  Z" d „  Z# d „  Z$ d „  Z% e j e& ƒ  d  ƒ d! „  ƒ Z' d" „  Z( e
 j) d# d$ ƒ d% „  ƒ Z* RS(&   c         C   sÁ   t  j t  j t  j t  j t  j t  j r6 t  j n  t  j d k rO t  j	 n  |  j
 t  j t t h ƒ |  j
 t  j t t h ƒ t  j t  j t  j t  j t  j d k r½ t  j t  j n  d  S(   Ni   i    (   i   i    (   i   i    i   (   R   t	   CERT_NONEt   CERT_OPTIONALt   CERT_REQUIREDR   R   t   HAS_ECDHR   R-   R   t   assertInt   HAS_SNIt   Truet   Falset   OP_NO_SSLv2t   OP_NO_SSLv3t   OP_NO_TLSv1t   OP_NO_TLSv1_3t   OP_NO_TLSv1_1t   OP_NO_TLSv1_2(   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_constantsÆ   s$    	

c         C   s“   t  j ƒ  } t j r> t j j d | | r0 d p3 d f ƒ n  t t  d ƒ r |  j t	 t  j
 d ƒ |  j t	 t  j
 d d ƒ n  t  j d d ƒ d  S(	   Ns   
 RAND_status is %d (%s)
s   sufficient randomnesss   insufficient randomnesst   RAND_egdi   t   foos   this is a random stringg     ÀR@(   R   t   RAND_statusR   R   R   R   R   RN   t   assertRaisest	   TypeErrorRs   t   RAND_add(   R&   t   v(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_randomÚ   s    	c         C   st  t  j j t ƒ } t j r? t j j d t	 j
 | ƒ d ƒ n  |  j | d d d d! d# f ƒ |  j | d t d ƒ ƒ |  j | d t d ƒ ƒ |  j | d d ƒ |  j | d d% d' d) d+ f ƒ |  j | d d- ƒ t  j j t ƒ } t j rt j j d t	 j
 | ƒ d ƒ n  |  j | d d. d/ f ƒ |  j | d d0 ƒ |  j | d d1 ƒ |  j | d d2 ƒ d  S(3   Ns   
t   issuert   countryNamet   XYt   localityNames   Castle Anthraxt   organizationNames   Python Software Foundationt
   commonNamet	   localhostt   notAfters   Aug 26 14:23:15 2028 GMTt	   notBefores   Aug 29 14:23:15 2018 GMTt   serialNumbert   98A7CF88C74A32EDt   subjectt   subjectAltNamet   DNSs   projects.developer.nokia.coms   projects.forum.nokia.comt   OCSPs   http://ocsp.verisign.comt	   caIssuerss0   http://SVRIntl-G3-aia.verisign.com/SVRIntlG3.cert   crlDistributionPointss0   http://SVRIntl-G3-crl.verisign.com/SVRIntlG3.crl(   R|   R}   (   (   R|   R}   (   R~   s   Castle Anthrax(   (   R~   s   Castle Anthrax(   R   s   Python Software Foundation(   (   R   s   Python Software Foundation(   R€   R�   (   (   R€   R�   (   R|   R}   (   (   R|   R}   (   R~   s   Castle Anthrax(   (   R~   s   Castle Anthrax(   R   s   Python Software Foundation(   (   R   s   Python Software Foundation(   R€   R�   (   (   R€   R�   (   Rˆ   R�   (   (   Rˆ   R�   (   Rˆ   s   projects.developer.nokia.com(   Rˆ   s   projects.forum.nokia.com(   s   http://ocsp.verisign.com(   s0   http://SVRIntl-G3-aia.verisign.com/SVRIntlG3.cer(   s0   http://SVRIntl-G3-crl.verisign.com/SVRIntlG3.crl(   R   t   _sslt   _test_decode_certt   CERTFILER   R   R   R   R   t   pprintt   pformatt   assertEqualR@   t	   NOKIACERT(   R&   t   p(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_parse_certå   s8    	$

	$
c         C   s�   t  j j t ƒ } t j r? t j j d t	 j
 | ƒ d ƒ n  |  j | i d d f d 6d d 6d	 d
 6d d 6d d f d 6d d 6d d 6ƒ d  S(   Ns   
R|   t   UKR€   s   cody-caR{   s   Jun 14 18:00:58 2028 GMTR‚   s   Jun 18 18:00:58 2018 GMTRƒ   t   02R„   s#   codenomicon-vm-2.test.lal.cisco.comR†   Rˆ   R‡   i   t   version(   R|   R•   (   (   R|   R•   (   R€   s   cody-ca(   (   R€   s   cody-ca(   R|   R•   (   (   R|   R•   (   R€   s#   codenomicon-vm-2.test.lal.cisco.com(   (   R€   s#   codenomicon-vm-2.test.lal.cisco.com(   Rˆ   s#   codenomicon-vm-2.test.lal.cisco.com(   (   Rˆ   s#   codenomicon-vm-2.test.lal.cisco.com(   R   RŒ   R�   t   TALOS_INVALID_CRLDPR   R   R   R   R   R�   R�   R‘   (   R&   R“   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_parse_cert_CVE_2019_5010  s    	$ 
c         C   sÖ   t  j j t ƒ } t j r? t j j d t	 j
 | ƒ d ƒ n  d! d# d% d' d) d+ d- f } |  j | d | ƒ |  j | d | ƒ t  j d. k r© d/ d0 d1 d2 d3 f } n d4 d5 d6 d7 d8 f } |  j | d | ƒ d  S(9   Ns   
R|   t   USt   stateOrProvinceNamet   OregonR~   t	   BeavertonR   s   Python Software Foundationt   organizationalUnitNames   Python Core DevelopmentR€   s   null.python.org example.orgt   emailAddresss   python-dev@python.orgR†   R{   i    i	   i   Rˆ   s   altnull.python.org example.comt   emails    null@python.org user@example.orgt   URIs)   http://null.python.org http://example.orgs
   IP Addresss	   192.0.2.1s   2001:DB8:0:0:0:0:0:1
s	   <invalid>R‡   (   R|   Rš   (   (   R|   Rš   (   R›   Rœ   (   (   R›   Rœ   (   R~   R�   (   (   R~   R�   (   R   s   Python Software Foundation(   (   R   s   Python Software Foundation(   Rž   s   Python Core Development(   (   Rž   s   Python Core Development(   R€   s   null.python.org example.org(   (   R€   s   null.python.org example.org(   RŸ   s   python-dev@python.org(   (   RŸ   s   python-dev@python.org(   i    i	   i   (   Rˆ   s   altnull.python.org example.com(   R    s    null@python.org user@example.org(   R¡   s)   http://null.python.org http://example.org(   s
   IP Addresss	   192.0.2.1(   s
   IP Addresss   2001:DB8:0:0:0:0:0:1
(   Rˆ   s   altnull.python.org example.com(   R    s    null@python.org user@example.org(   R¡   s)   http://null.python.org http://example.org(   s
   IP Addresss	   192.0.2.1(   s
   IP Addresss	   <invalid>(   R   RŒ   R�   t   NULLBYTECERTR   R   R   R   R   R�   R�   R‘   R+   (   R&   R“   R†   t   san(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_parse_cert_CVE_2013_4238"  s0    	$		c         C   sZ   t  j j t ƒ } |  j | d d d d d d d	 d d! d# d% f f d& d' d( d) f
 ƒ d  S(*   NR‡   Rˆ   t   allsanst	   othernames   <unsupported>R    s   user@example.orgs   www.example.orgt   DirNameR|   R}   R~   s   Castle AnthraxR   s   Python Software FoundationR€   s   dirname exampleR¡   s   https://www.python.org/s
   IP Addresss	   127.0.0.1s   0:0:0:0:0:0:0:1
s   Registered IDs	   1.2.3.4.5(   Rˆ   R¥   (   R¦   s   <unsupported>(   R¦   s   <unsupported>(   R    s   user@example.org(   Rˆ   s   www.example.org(   R|   R}   (   (   R|   R}   (   R~   s   Castle Anthrax(   (   R~   s   Castle Anthrax(   R   s   Python Software Foundation(   (   R   s   Python Software Foundation(   R€   s   dirname example(   (   R€   s   dirname example(   R¡   s   https://www.python.org/(   s
   IP Addresss	   127.0.0.1(   s
   IP Addresss   0:0:0:0:0:0:0:1
(   s   Registered IDs	   1.2.3.4.5(   R   RŒ   R�   t
   ALLSANFILER‘   (   R&   R“   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_parse_all_sans?  s     	c         C   s½   t  t d ƒ � } | j ƒ  } Wd  QXt j | ƒ } t j | ƒ } t j | ƒ } |  j | | ƒ | j t j d ƒ s‹ |  j	 d | ƒ n  | j
 d t j d ƒ s¹ |  j	 d | ƒ n  d  S(   NRS   s   
s-   DER-to-PEM didn't include correct header:
%r
s-   DER-to-PEM didn't include correct footer:
%r
(   RW   t   CAFILE_CACERTt   readR   t   PEM_cert_to_DER_certt   DER_cert_to_PEM_certR‘   t
   startswitht
   PEM_HEADERt   failt   endswitht
   PEM_FOOTER(   R&   RM   t   pemt   d1t   p2t   d2(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_DER_to_PEMT  s    c   	      C   s’  t  j } t  j } t  j } |  j | t t f ƒ |  j | t ƒ |  j | t ƒ |  j	 | d ƒ |  j
 | d ƒ | \ } } } } } |  j	 | d ƒ |  j
 | d ƒ |  j	 | d ƒ |  j
 | d ƒ |  j	 | d ƒ |  j
 | d ƒ |  j	 | d ƒ |  j | d ƒ |  j	 | d ƒ |  j | d ƒ t r`|  j | j d j | ƒ ƒ | | t | ƒ f ƒ n. |  j | j d	 j | | | ƒ ƒ | | f ƒ d  S(
   Ni  � i   0i    i   i   i?   i   s   LibreSSL {:d}s   OpenSSL {:d}.{:d}.{:d}(   R   t   OPENSSL_VERSION_NUMBERR-   t   OPENSSL_VERSIONt   assertIsInstancet   intt   longt   tuplet   strt   assertGreaterEqualt
   assertLesst   assertLessEqualt   IS_LIBRESSLt
   assertTrueR®   t   formatt   hex(	   R&   t   nt   tt   st   majort   minort   fixt   patcht   status(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_openssl_version`  s0    			!c         C   sJ   t  j  t  j ƒ } t j | ƒ } t j | ƒ } ~ |  j | ƒ  d  ƒ d  S(   N(   R!   R"   R   t   wrap_sockett   weakreft   refR‘   t   None(   R&   RÈ   t   sst   wr(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_refcycle  s
    c      
   C   sï   t  j  t  j ƒ } t t j | ƒ ƒ �Â } |  j t  j | j d ƒ |  j t  j | j t	 d ƒ ƒ |  j t  j | j
 d ƒ |  j t  j | j t	 d ƒ d ƒ |  j t  j | j d ƒ |  j t  j | j d d ƒ |  j t | j ƒ Wd  QXd  S(   Ni   t   xs   0.0.0.0i    (   s   0.0.0.0i    (   R!   R"   R   R   RÏ   Rv   t   errort   recvt	   recv_intot	   bytearrayt   recvfromt   recvfrom_intot   sendt   sendtot   NotImplementedErrort   dup(   R&   RÈ   RÓ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_wrapped_unconnected‰  s    "c         C   sh   xa d D]Y } t j t j ƒ } | j | ƒ t t j | ƒ ƒ � } |  j | | j ƒ  ƒ Wd  QXq Wd  S(   Ng        g      @(   Ng        g      @(	   RÒ   R!   R"   t
   settimeoutR   R   RÏ   R‘   t
   gettimeout(   R&   t   timeoutRÈ   RÓ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_timeout–  s
    c         C   så  t  j  ƒ  } |  j t d t j | d t ƒ|  j t d t j | d t ƒ|  j t d t j | d t d d ƒt t j | d t d t ƒƒ �& } |  j t d | j t	 d f ƒ Wd  QX|  j
 t ƒ �5 } t t  j  ƒ  ƒ � } t j | d t ƒWd  QXWd  QX|  j | j j t j ƒ |  j
 t ƒ �; } t t  j  ƒ  ƒ �  } t j | d t d t ƒWd  QXWd  QX|  j | j j t j ƒ |  j
 t ƒ �; } t t  j  ƒ  ƒ �  } t j | d t d t ƒWd  QXWd  QX|  j | j j t j ƒ d  S(	   Ns   certfile must be specifiedt   keyfiles5   certfile must be specified for server-side operationst   server_sidet   certfileRC   s!   can't connect in server-side modei�  (   R!   t   assertRaisesRegexpt
   ValueErrorR   RÏ   RŽ   Rj   R   t   connectt   HOSTRv   R#   t   NONEXISTINGCERTR‘   t	   exceptionR$   t   ENOENT(   R&   t   sockRÈ   t   cm(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_errorsŸ  s6    			$c      
   C   s   t  j j t  j j t ƒ p! t  j | ƒ } t j ƒ  } |  j | j ƒ |  j	 t
 j ƒ �! t
 j | d | d t
 j ƒWd QXd S(   s;   Check that trying to use the given client certificate failsRè   t   ssl_versionN(   R   R   R   R   R	   t   curdirR!   t
   addCleanupt   closeRv   R   RE   RÏ   t   PROTOCOL_TLSv1(   R&   Rè   Rð   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   bad_cert_test¼  s    !	c         C   s   |  j  d ƒ d S(   s    Wrapping with an empty cert files   nullcert.pemN(   Rø   (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_empty_certÇ  s    c         C   s   |  j  d ƒ d S(   s:   Wrapping with a badly formatted certificate (syntax error)s   badcert.pemN(   Rø   (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_malformed_certË  s    c         C   s   |  j  d ƒ d S(   s2   Wrapping with a badly formatted key (syntax error)s
   badkey.pemN(   Rø   (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_malformed_keyÏ  s    c            sÉ  d „  } ‡  f d †  } i dE d 6} | | d ƒ | | d ƒ | | d ƒ | | d ƒ | | d	 ƒ | | d
 ƒ i dH d 6} | | d ƒ | | d ƒ | | d ƒ | | d ƒ | | d ƒ i dK d 6} | | d ƒ | | d ƒ | | d ƒ | | d ƒ | | d ƒ i dN d 6} | | d ƒ | | d	 ƒ | | d ƒ i dQ d 6} | | d ƒ | | d ƒ | | d ƒ | | d ƒ i dT d 6} | | d ƒ | | d ƒ | | d ƒ d j  d ƒ j d ƒ } i d | f f f d 6} | | | ƒ i dW d 6} | | | ƒ i dZ d 6} | | | ƒ d! j  d ƒ j d ƒ } i d | f f f d 6} | | d" j  d ƒ j d ƒ ƒ | | d# j  d ƒ j d ƒ ƒ | | d$ j  d ƒ j d ƒ ƒ | | d% j  d ƒ j d ƒ ƒ i d& d' 6d] d 6d^ d_ d` f d. 6} | | d* ƒ | | d+ ƒ | | d- ƒ | | d( ƒ i d/ d' 6db dd df dh dj f d 6} | | d8 ƒ | | d9 ƒ | | d3 ƒ i d/ d' 6dl dn dp dr f d 6} | | d8 ƒ i d: d' 6dt dv dx dz f d 6d| d. 6} | | d8 ƒ i d: d' 6d~ d€ d‚ d„ f d 6d† d. 6} | | d< ƒ ˆ  j t t j d  d ƒ ˆ  j t t j i  d ƒ i d‰ d 6} | | d> ƒ i dŒ d 6} | | d> ƒ i d� d 6} ˆ  j t j ƒ � } t j | dA ƒ Wd  QXˆ  j dB t	 | j
 ƒ ƒ d  S(�   Nc         S   s   t  j |  | ƒ d  S(   N(   R   t   match_hostname(   t   certt   hostname(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   okÔ  s    c            s    ˆ  j  t j t j |  | ƒ d  S(   N(   Rv   R   t   CertificateErrorRü   (   Rý   Rþ   (   R&   (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR°   Ö  s    R€   s   example.comR†   s   ExAmple.cOms   www.example.coms   .example.coms   example.orgt   exampleXcoms   *.a.coms	   foo.a.coms   bar.foo.a.coms   a.coms   Xa.coms   .a.coms   f*.coms   foo.coms   f.coms   bar.coms   bar.foo.coms   null.python.org example.orgs   null.python.orgs	   *.*.a.coms   a.*.coms	   a.foo.coms   a..comu   pÃ¼thon.python.orgt   idnat   asciis   x*.python.orgs   xn--p*.python.orgu   www*.pythÃ¶n.orgu   www.pythÃ¶n.orgu   www1.pythÃ¶n.orgu   ftp.pythÃ¶n.orgu   pythÃ¶n.orgs   Jun 26 21:41:46 2011 GMTR‚   s   linuxfrz.orgRˆ   s   linuxfr.orgs   linuxfr.comR¦   s   <unsupported>R‡   s   Dec 18 23:59:59 2011 GMTR|   Rš   R›   t
   CaliforniaR~   s   Mountain ViewR   s
   Google Incs   mail.google.coms	   gmail.coms   Dec 18 23:59:59 2099 GMTt   blablas
   google.coms   a*b.coms   axxb.coms   a*b.co*s   a*b*.coms   axxbxxc.coms   too many wildcards(   R€   s   example.com(   (   R€   s   example.com(   (   (   R€   s   example.com(   R€   s   *.a.com(   (   R€   s   *.a.com(   (   (   R€   s   *.a.com(   R€   s   f*.com(   (   R€   s   f*.com(   (   (   R€   s   f*.com(   R€   s   null.python.org example.org(   (   R€   s   null.python.org example.org(   (   (   R€   s   null.python.org example.org(   R€   s	   *.*.a.com(   (   R€   s	   *.*.a.com(   (   (   R€   s	   *.*.a.com(   R€   s   a.*.com(   (   R€   s   a.*.com(   (   (   R€   s   a.*.com(   R€   s   x*.python.org(   (   R€   s   x*.python.org(   (   (   R€   s   x*.python.org(   R€   s   xn--p*.python.org(   (   R€   s   xn--p*.python.org(   (   (   R€   s   xn--p*.python.org(   R€   s   linuxfrz.org(   (   R€   s   linuxfrz.org(   (   (   R€   s   linuxfrz.org(   Rˆ   s   linuxfr.org(   Rˆ   s   linuxfr.com(   R¦   s   <unsupported>(   R|   Rš   (   (   R|   Rš   (   R›   R  (   (   R›   R  (   R~   s   Mountain View(   (   R~   s   Mountain View(   R   s
   Google Inc(   (   R   s
   Google Inc(   R€   s   mail.google.com(   (   R€   s   mail.google.com(   R|   Rš   (   (   R|   Rš   (   R›   R  (   (   R›   R  (   R~   s   Mountain View(   (   R~   s   Mountain View(   R   s
   Google Inc(   (   R   s
   Google Inc(   R|   Rš   (   (   R|   Rš   (   R›   R  (   (   R›   R  (   R~   s   Mountain View(   (   R~   s   Mountain View(   R€   s   mail.google.com(   (   R€   s   mail.google.com(   R¦   R  (   (   R¦   R  (   R|   Rš   (   (   R|   Rš   (   R›   R  (   (   R›   R  (   R~   s   Mountain View(   (   R~   s   Mountain View(   R   s
   Google Inc(   (   R   s
   Google Inc(   R¦   R  (   (   R¦   R  (   R€   s   a*b.com(   (   R€   s   a*b.com(   (   (   R€   s   a*b.com(   R€   s   a*b.co*(   (   R€   s   a*b.co*(   (   (   R€   s   a*b.co*(   R€   s   a*b*.com(   (   R€   s   a*b*.com(   (   (   R€   s   a*b*.com(   t   encodet   decodeRv   Rê   R   Rü   RÒ   R   Rh   R¾   Rî   (   R&   Rÿ   R°   Rý   R  Rñ   (    (   R&   sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_match_hostnameÓ  sÀ    	









c         C   sP   t  j t  j ƒ } t t j ƒ  ƒ �& } |  j t | j | t d d ƒWd  QXd  S(   Nt   server_hostnames   some.hostname(	   R   RD   t   PROTOCOL_SSLv23R   R!   Rv   Rê   RÏ   Rj   (   R&   t   ctxRð   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_server_sideX  s    c      
   C   sW   t  j  t  j ƒ } t t j | ƒ ƒ �* } |  j t ƒ � | j d ƒ Wd  QXWd  QXd  S(   Ns   unknown-type(   R!   R"   R   R   RÏ   Rv   Rê   t   get_channel_binding(   R&   RÈ   RÓ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_unknown_channel_binding_  s    s
   tls-uniques*   'tls-unique' channel binding not availablec         C   sœ   t  j  t  j ƒ } t t j | ƒ ƒ � } |  j | j d ƒ ƒ Wd  QXt  j  t  j ƒ } t t j | d t d t ƒƒ � } |  j | j d ƒ ƒ Wd  QXd  S(   Ns
   tls-uniqueRç   Rè   (	   R!   R"   R   R   RÏ   t   assertIsNoneR  Rj   RŽ   (   R&   RÈ   RÓ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_tls_unique_channel_bindingf  s    $c         C   s”   t  j ƒ  } |  j t | ƒ d ƒ |  j | t  j ƒ t j ƒ  �M } t | d <t	 | d <t  j ƒ  } |  j | j
 t	 ƒ |  j | j t ƒ Wd  QXd  S(   Ni   t   SSL_CERT_DIRt   SSL_CERT_FILE(   R   t   get_default_verify_pathsR‘   t   lenRº   t   DefaultVerifyPathsR   t   EnvironmentVarGuardt   CAPATHRŽ   t   cafileR   (   R&   t   pathst   env(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_get_default_verify_pathsr  s    

t   win32s   Windows specificc   	      C   sI  |  j  t j d ƒ ƒ |  j  t j d ƒ ƒ |  j t t j ƒ |  j t t j d ƒ t ƒ  } xÎ d D]Æ } t j | ƒ } |  j | t ƒ xž | D]– } |  j | t	 ƒ |  j
 t | ƒ d ƒ | \ } } } |  j | t ƒ |  j | d d h ƒ |  j | t t f ƒ t | t ƒ r‘ | j | ƒ q‘ q‘ Wqe Wd } |  j | | ƒ d  S(	   Nt   CAt   ROOTRC   i   t   x509_asnt
   pkcs_7_asns   1.3.6.1.5.5.7.3.1(   R  R  (   RÃ   R   t   enum_certificatesRv   Rw   t   WindowsErrort   setRº   t   listR½   R‘   R  t   bytesRh   t   boolt
   isinstancet   update(	   R&   t
   trust_oidst	   storenamet   storet   elementRý   t   enct   trustt
   serverAuth(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_enum_certificates~  s&    	c         C   sÇ   |  j  t j d ƒ ƒ |  j t t j ƒ |  j t t j d ƒ t j d ƒ } |  j | t ƒ xb | D]Z } |  j | t ƒ |  j	 t
 | ƒ d ƒ |  j | d t ƒ |  j | d d d h ƒ qe Wd  S(   NR  RC   i   i    i   R  R   (   RÃ   R   t	   enum_crlsRv   Rw   R"  Rº   R$  R½   R‘   R  R%  Rh   (   R&   t   crlsR,  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_enum_crls—  s    c         C   sD  d } t  j d ƒ } |  j | | ƒ |  j | j d ƒ |  j | j d ƒ |  j | j d ƒ |  j | j d ƒ |  j | t  j ƒ |  j t	 t  j d ƒ t  j j
 d ƒ } |  j | | ƒ |  j | t  j ƒ |  j t	 t  j j
 d ƒ |  j t	 d ƒ � t  j j
 d ƒ Wd  QXx– t d ƒ D]ˆ } y t  j j
 | ƒ } Wn t	 k
 rMqX|  j | j t ƒ |  j | j t ƒ |  j | j t ƒ |  j | j t t d  ƒ f ƒ qWt  j j d ƒ } |  j | | ƒ |  j | t  j ƒ |  j t  j j d ƒ | ƒ |  j t  j j d ƒ | ƒ |  j t	 d	 ƒ � t  j j d
 ƒ Wd  QXd  S(   Ni�   R/  s   TLS Web Server Authentications   1.3.6.1.5.5.7.3.1iÿÿÿÿs   unknown NID 100000i † iè  s   unknown object 'serverauth't
   serverauth(   i�   R/  s   TLS Web Server Authentications   1.3.6.1.5.5.7.3.1(   R   t   _ASN1ObjectR‘   t   nidt	   shortnamet   longnamet   oidRº   Rv   Rê   t   fromnidRé   t   rangeR»   R¾   t   typeRÒ   t   fromname(   R&   t   expectedt   valt   it   obj(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_asn1object¦  sB     #c         C   s  t  j d ƒ } |  j t  j j t  j ƒ |  j t  j j | ƒ |  j t  j j j d ƒ |  j t  j j j d ƒ |  j t  j j j d ƒ t  j d ƒ } |  j t  j j	 t  j ƒ |  j t  j j	 | ƒ |  j t  j j	 j d ƒ |  j t  j j	 j d ƒ |  j t  j j	 j d ƒ d  S(   Ns   1.3.6.1.5.5.7.3.1i�   R/  s   1.3.6.1.5.5.7.3.2i‚   t
   clientAuth(
   R   R5  Rº   t   Purposet   SERVER_AUTHR‘   R6  R7  R9  t   CLIENT_AUTH(   R&   R?  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_purpose_enumÍ  s    c         C   sÃ   t  j  t  j t  j ƒ } |  j | j ƒ |  j t ƒ � } t j | d t j	 ƒWd  QX|  j
 t | j ƒ d ƒ t j t j ƒ } |  j t ƒ � } | j | ƒ Wd  QX|  j
 t | j ƒ d ƒ d  S(   Nt	   cert_reqss!   only stream sockets are supported(   R!   R"   t
   SOCK_DGRAMRõ   Rö   Rv   Rß   R   RÏ   Rd   R‘   R¾   Rî   RD   R
  (   R&   RÈ   t   cxR  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_unsupported_dtlsÞ  s    c         C   s   |  j  t j | ƒ | ƒ d  S(   N(   R‘   R   t   cert_time_to_seconds(   R&   t
   timestringt	   timestamp(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   cert_time_oké  s    c         C   s'   |  j  t ƒ � t j | ƒ Wd  QXd  S(   N(   Rv   Rê   R   RL  (   R&   RM  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   cert_time_failì  s    s)   local time needs to be different from UTCc         C   s$   |  j  d d ƒ |  j  d d ƒ d  S(   Ns   May  9 00:00:00 2007 GMTg   ÀC�ÑAs   Jan  5 09:34:43 2018 GMTg  À¬Ñ“ÖA(   RO  (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt"   test_cert_time_to_seconds_timezoneð  s    c         C   s*  d } d } |  j  | | ƒ |  j t j d | ƒ | ƒ |  j  d | ƒ |  j  d | ƒ |  j d ƒ |  j d ƒ |  j d ƒ |  j d	 ƒ |  j d
 ƒ |  j d ƒ |  j d ƒ d } |  j  d | ƒ |  j  d | ƒ |  j  d d ƒ |  j  d d ƒ |  j  d d ƒ |  j d ƒ |  j  d d ƒ d  S(   Ns   Jan  5 09:34:43 2018 GMTg  À¬Ñ“ÖAR=   s   Jan 05 09:34:43 2018 GMTs   JaN  5 09:34:43 2018 GmTs   Jan  5 09:34 2018 GMTs   Jan  5 09:34:43 2018s   Jan  5 09:34:43 2018 UTCs   Jan 35 09:34:43 2018 GMTs   Jon  5 09:34:43 2018 GMTs   Jan  5 24:00:00 2018 GMTs   Jan  5 09:60:43 2018 GMTg   àWÒAs   Dec 31 23:59:60 2008 GMTs   Jan  1 00:00:00 2009 GMTs   Jan  5 09:34:59 2018 GMTiÃFOZs   Jan  5 09:34:60 2018 GMTiÄFOZs   Jan  5 09:34:61 2018 GMTiÅFOZs   Jan  5 09:34:62 2018 GMTs   Dec 31 23:59:59 9999 GMTg €¿ úMB(   RO  R‘   R   RL  RP  (   R&   RM  t   tst
   newyear_ts(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_cert_time_to_secondsø  s*    t   LC_ALLRC   c         C   sV   d „  } | ƒ  j  ƒ  d k r. |  j d ƒ n  |  j d d ƒ |  j | ƒ  d ƒ d  S(   Nc           S   s   t  j d d	 ƒ S(
   Ns   %bi   i   i   i   i   i   i    (	   i   i   i   i   i   i   i    i    i    (   R0   R<   (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   local_february_name  s    t   febs>   locale-specific month name needs to be different from C locales   Feb  9 00:00:00 2007 GMTg   `îrÑAs     9 00:00:00 2007 GMT(   t   lowert   skipTestRO  RP  (   R&   RV  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt    test_cert_time_to_seconds_locale  s
    	(+   R)   R*   Rr   Rz   R”   R™   R¤   R©   R·   RÎ   R   t   cpython_onlyRÕ   Rá   Rå   Rò   Rø   Rù   Rú   Rû   R  R  R  RH   t
   skipUnlessR   t   CHANNEL_BINDING_TYPESR  R  R   RF   R0  R3  RB  RG  RK  RO  RP  R6   RQ  RT  t   run_with_localeRZ  (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRc   Ä   sB   			(					
									…			$$	'					#t   ContextTestsc           B   sˆ  e  Z e d  „  ƒ Z e d „  ƒ Z d „  Z e d „  ƒ Z d „  Z e j	 e
 ƒ  d ƒ d „  ƒ Z d „  Z d „  Z d	 „  Z d
 „  Z e d „  ƒ Z d „  Z e j	 e j d ƒ d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z d „  Z d „  Z e j e j d k d ƒ e j e d ƒ d „  ƒ ƒ Z e j	 e j d k d ƒ d „  ƒ Z  d „  Z! d „  Z" d „  Z# d „  Z$ d „  Z% d „  Z& RS(    c         C   sa   x t  D] } t j | ƒ q W|  j t t j ƒ |  j t t j d ƒ |  j t t j d ƒ d  S(   Niÿÿÿÿi*   (   t	   PROTOCOLSR   RD   Rv   Rw   Rê   (   R&   t   protocol(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_constructor-  s
    c         C   s7   x0 t  D]( } t j | ƒ } |  j | j | ƒ q Wd  S(   N(   R`  R   RD   R‘   Ra  (   R&   t   protoR  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_protocol5  s    c         C   sY   t  j t  j ƒ } | j d ƒ | j d ƒ |  j t  j d ƒ � | j d ƒ Wd  QXd  S(   Nt   ALLt   DEFAULTs   No cipher can be selecteds   ^$:,;?*'dorothyx(   R   RD   R÷   t   set_ciphersRé   RE   (   R&   R  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_ciphers;  s
    c         C   sü   t  j t  j ƒ } t  j t  j Bt  j B} | t t Bt Bt	 Bt
 BO} |  j | | j ƒ | j t  j O_ |  j | t  j B| j ƒ t ƒ  rÙ | j t  j @| _ |  j | | j ƒ d | _ |  j d | j t  j @ƒ n |  j t ƒ � d | _ Wd  QXd  S(   Ni    (   R   RD   R÷   t   OP_ALLRl   Rm   R   R   R   R   R   R‘   t   optionsRn   R,   Rv   Rê   (   R&   R  t   default(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_optionsB  s    		c         C   sÐ   t  j t  j ƒ } |  j | j t  j ƒ t  j | _ |  j | j t  j ƒ t  j | _ |  j | j t  j ƒ t  j | _ |  j | j t  j ƒ |  j t	 ƒ � d  | _ Wd  QX|  j t ƒ � d | _ Wd  QXd  S(   Ni*   (   R   RD   R÷   R‘   t   verify_modeRd   Re   Rf   Rv   Rw   RÒ   Rê   (   R&   R  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_verify_modeX  s    s!   verify_flags need OpenSSL > 0.9.8c         C   s÷   t  j t  j ƒ } t t  d d ƒ } |  j | j t  j | Bƒ t  j | _ |  j | j t  j ƒ t  j | _ |  j | j t  j ƒ t  j | _ |  j | j t  j ƒ t  j t  j	 B| _ |  j | j t  j t  j	 Bƒ |  j
 t ƒ � d  | _ Wd  QXd  S(   Nt   VERIFY_X509_TRUSTED_FIRSTi    (   R   RD   R÷   t   getattrR‘   t   verify_flagst   VERIFY_DEFAULTt   VERIFY_CRL_CHECK_LEAFt   VERIFY_CRL_CHECK_CHAINt   VERIFY_X509_STRICTRv   Rw   RÒ   (   R&   R  t   tf(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_verify_flagsg  s    c         C   s�  t  j t  j ƒ } | j t d d  ƒ| j t d t ƒ|  j t | j d t ƒ|  j t ƒ � } | j t	 ƒ Wd  QX|  j
 | j j t j ƒ |  j t  j d ƒ � | j t ƒ Wd  QX|  j t  j d ƒ � | j t ƒ Wd  QXt  j t  j ƒ } | j t t ƒ | j d t d t ƒ | j d t d t ƒ |  j t  j d ƒ � | j t ƒ Wd  QX|  j t  j d ƒ � | j t ƒ Wd  QX|  j t  j d ƒ � | j d t d t ƒ Wd  QXt  j t  j ƒ } |  j t  j d ƒ � | j t t ƒ Wd  QX| j t d t ƒ| j t d t j ƒ  ƒ| j t d t t j ƒ  ƒ ƒ| j t t t ƒ | j t t t j ƒ  ƒ | j t t t t j ƒ  ƒ ƒ |  j t d ƒ � | j t d t ƒWd  QX|  j t  j ƒ � | j t d d ƒWd  QX|  j t d ƒ � | j t d d	 d
 ƒWd  QXd „  } d „  } d „  } d „  } d „  } d „  } d „  }	 d d d „  ƒ  Y}
 | j t d | ƒ| j t d | ƒ| j t d | ƒ| j t d |
 ƒ  ƒ| j t d |
 ƒ  j ƒ|  j t  j ƒ � | j t d | ƒWd  QX|  j t d ƒ � | j t d | ƒWd  QX|  j t d ƒ � | j t d | ƒWd  QX|  j t d ƒ � | j t d |	 ƒWd  QX| j t d |	 ƒd  S(   NRæ   s   PEM libRè   s   key values mismatcht   passwords   should be a stringt   badpasss   cannot be longert   ai � c           S   s   t  S(   N(   t   KEY_PASSWORD(    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   getpass_unicodeª  s    c           S   s
   t  j ƒ  S(   N(   R{  R  (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   getpass_bytes¬  s    c           S   s   t  t j ƒ  ƒ S(   N(   RÚ   R{  R  (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   getpass_bytearray®  s    c           S   s   d S(   NRy  (    (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   getpass_badpass°  s    c           S   s   d d S(   NRz  i   i   (    (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   getpass_huge²  s    c           S   s   d S(   Ni	   (    (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   getpass_bad_type´  s    c           S   s   t  d ƒ ‚ d  S(   Ns   getpass error(   t	   Exception(    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   getpass_exception¶  s    t   GetPassCallablec           B   s   e  Z d  „  Z d „  Z RS(   c         S   s   t  S(   N(   R{  (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   __call__¹  s    c         S   s   t  S(   N(   R{  (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   getpass»  s    (   R)   R*   R…  R†  (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR„  ¸  s   	s   must return a strings   getpass error(    (    R   RD   R÷   t   load_cert_chainRŽ   RÒ   Rv   Rw   R#   Rí   R‘   Rî   R$   Rï   Ré   RE   t   BADCERTt	   EMPTYCERTt   ONLYCERTt   ONLYKEYt   BYTES_ONLYCERTt   BYTES_ONLYKEYRª   t   CERTFILE_PROTECTEDR{  R  RÚ   t   ONLYKEY_PROTECTEDRj   Rê   R†  R‚  (   R&   R  Rñ   R|  R}  R~  R  R€  R�  Rƒ  R„  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_load_cert_chain{  sz    							c         C   sj  t  j t  j ƒ } | j t ƒ | j d t d d  ƒ | j t ƒ | j d t d d  ƒ | j d t j d ƒ ƒ |  j t	 | j ƒ |  j t	 | j d  d  d  ƒ |  j t
 ƒ � } | j t ƒ Wd  QX|  j | j j t j ƒ |  j t
 ƒ � | j d ƒ Wd  QX|  j t  j d ƒ � | j t ƒ Wd  QX| j t t ƒ | j t d t ƒ|  j t	 | j d  t ƒ d  S(   NR  R   s   utf-8u    s   PEM lib(   R   RD   R÷   t   load_verify_locationsRŽ   RÒ   t   BYTES_CERTFILER  Rv   Rw   R#   Rí   R‘   Rî   R$   Rï   Ré   RE   Rˆ  R  t   BYTES_CAPATHRj   (   R&   R  Rñ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_load_verify_locationsÎ  s$    c      
   C   s  t  t ƒ � } | j ƒ  j d ƒ } Wd  QXt j | ƒ } t  t ƒ � } | j ƒ  j d ƒ } Wd  QXt j | ƒ } t j t j ƒ } |  j	 | j
 ƒ  d d ƒ | j d | ƒ |  j	 | j
 ƒ  d d ƒ | j d | ƒ |  j	 | j
 ƒ  d d ƒ | j d | ƒ |  j	 | j
 ƒ  d d ƒ t j t j ƒ } d j | | f ƒ } | j d | ƒ |  j	 | j
 ƒ  d d ƒ t j t j ƒ } d | d	 | d
 | d g } | j d d j | ƒ ƒ |  j	 | j
 ƒ  d d ƒ t j t j ƒ } | j d | ƒ | j d | ƒ |  j	 | j
 ƒ  d d ƒ | j d | ƒ |  j	 | j
 ƒ  d d ƒ t j t j ƒ } d j | | f ƒ } | j d | ƒ |  j	 | j
 ƒ  d d ƒ t j t j ƒ } |  j t | j d t ƒ|  j t j d ƒ � | j d d ƒ Wd  QX|  j t j d ƒ � | j d d ƒ Wd  QXd  S(   NR  t   x509_cai    t   cadatai   i   s   
t   headt   othert   againt   tailRC   s   no start lineu   brokens   not enough datat   broken(   RW   Rª   R«   R  R   R¬   t   CAFILE_NEURONIORD   R÷   R‘   t   cert_store_statsR‘  R   Rv   Rw   t   objectRé   RE   (   R&   RM   t
   cacert_pemt
   cacert_dert   neuronio_pemt   neuronio_derR  t   combined(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_load_verify_cadataä  sN    c      	   C   sf  d } t  j ƒ  } y | j | ƒ Wn( t k
 rM |  j d | | f ƒ n Xt j t j ƒ } | j t	 ƒ t
 j d k rŒ | j t ƒ n  |  j t | j ƒ |  j t | j d  ƒ |  j t ƒ � } | j t ƒ Wd  QX|  j | j j t j ƒ |  j t j ƒ � } | j t ƒ Wd  QXt j ƒ  �9 } t
 j j | | ƒ } t j t	 | ƒ | j | ƒ Wd  QXd  S(   Nu   dhpÃ¤rÃ¤m.pems;   filename %r cannot be encoded to the filesystem encoding %rt   nt(   R   t   getfilesystemencodingR  t   UnicodeEncodeErrorRY  R   RD   R÷   t   load_dh_paramst   DHFILER   R
   t   BYTES_DHFILERv   Rw   RÒ   R#   Rí   R‘   Rî   R$   Rï   RE   RŽ   R   t   temp_dirR   R   t   shutilt   copy(   R&   t   filenamet   fs_encodingR  Rñ   t   dt   fname(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_load_dh_params  s*    c         C   s‡   x€ t  D]x } t j | ƒ } |  j | j ƒ  i d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d	 6d d
 6d d 6d d 6ƒ q Wd  S(   Ni    t   numberRë   t   connect_goodt   connect_renegotiatet   acceptt   accept_goodt   accept_renegotiatet   hitst   missest   timeoutst
   cache_full(   R`  R   RD   R‘   t   session_stats(   R&   Rc  R  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_session_stats6  s    c         C   s    t  j t  j ƒ } | j ƒ  d  S(   N(   R   RD   R÷   t   set_default_verify_paths(   R&   R  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_set_default_verify_pathsH  s    s#   ECDH disabled on this OpenSSL buildc         C   s…   t  j t  j ƒ } | j d ƒ | j d ƒ |  j t | j ƒ |  j t | j d  ƒ |  j t | j d ƒ |  j t | j d ƒ d  S(   Nt
   prime256v1Rt   (   R   RD   R÷   t   set_ecdh_curveRv   Rw   RÒ   Rê   (   R&   R  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_set_ecdh_curveN  s    c         C   sŽ   t  j t  j ƒ } |  j t | j ƒ |  j t | j d ƒ |  j t | j d ƒ |  j t | j | ƒ d „  } | j d  ƒ | j | ƒ d  S(   Ni   RC   c         S   s   d  S(   N(    (   Rð   t
   servernameR  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   dummycallbackb  s    (   R   RD   R÷   Rv   Rw   t   set_servername_callbackRÒ   (   R&   R  RÅ  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_sni_callbackX  s    	c         C   sa   t  j t  j ƒ } | d „ } | j | ƒ t j | ƒ } ~ ~ t j ƒ  |  j | ƒ  d  ƒ d  S(   Nc         S   s   d  S(   N(    (   Rð   RÄ  R  t   cycle(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRÅ  l  s    (
   R   RD   R÷   RÆ  RÐ   RÑ   t   gct   collectt   assertIsRÒ   (   R&   R  RÅ  RÔ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_sni_callback_refcycleg  s    
c         C   sé   t  j t  j ƒ } |  j | j ƒ  i d d 6d d 6d d 6ƒ | j t ƒ |  j | j ƒ  i d d 6d d 6d d 6ƒ | j t ƒ |  j | j ƒ  i d d 6d d 6d d 6ƒ | j t ƒ |  j | j ƒ  i d d 6d d 6d d 6ƒ d  S(   Ni    R•  t   crlt   x509i   i   (	   R   RD   R÷   R‘   R�  R‡  RŽ   R‘  Rª   (   R&   R  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_cert_store_statst  s    c         C   s  t  j t  j ƒ } |  j | j ƒ  g  ƒ | j t ƒ |  j | j ƒ  g  ƒ | j t ƒ |  j | j ƒ  i d d d d f d	 6t d
 ƒ d 6t d ƒ d 6d d 6d d 6d d! d# d% f d 6d d 6g ƒ t	 t ƒ � } | j
 ƒ  } Wd  QXt  j | ƒ } |  j | j t ƒ | g ƒ d  S(&   NR   s   Root CARž   s   http://www.cacert.orgR€   s   CA Cert Signing AuthorityRŸ   s   support@cacert.orgR{   s   Mar 29 12:29:49 2033 GMTR‚   s   Mar 30 12:29:49 2003 GMTRƒ   t   00R„   s!   https://www.cacert.org/revoke.crlR‹   R†   i   R—   (   R   s   Root CA(   (   R   s   Root CA(   Rž   s   http://www.cacert.org(   (   Rž   s   http://www.cacert.org(   R€   s   CA Cert Signing Authority(   (   R€   s   CA Cert Signing Authority(   RŸ   s   support@cacert.org(   (   RŸ   s   support@cacert.org(   s!   https://www.cacert.org/revoke.crl(   R   s   Root CA(   (   R   s   Root CA(   Rž   s   http://www.cacert.org(   (   Rž   s   http://www.cacert.org(   R€   s   CA Cert Signing Authority(   (   R€   s   CA Cert Signing Authority(   RŸ   s   support@cacert.org(   (   RŸ   s   support@cacert.org(   R   RD   R÷   R‘   t   get_ca_certsR‘  RŽ   Rª   R@   RW   R«   R¬   Rj   (   R&   R  RM   R³   t   der(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_get_ca_certs‚  s.    

c         C   s²   t  j t  j ƒ } | j ƒ  t  j t  j ƒ } | j t  j j ƒ | j ƒ  t  j t  j ƒ } | j t  j j ƒ t  j t  j ƒ } |  j t | j d  ƒ |  j t | j d ƒ d  S(   NRE  (
   R   RD   R÷   t   load_default_certsRD  RE  RF  Rv   Rw   RÒ   (   R&   R  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_load_default_certsž  s    

R  s   not-Windows specifics!   LibreSSL doesn't support env varsc      	   C   st   t  j t  j ƒ } t j ƒ  �P } t | d <t | d <| j ƒ  |  j | j	 ƒ  i d d 6d d 6d d 6ƒ Wd  QXd  S(   NR  R  i    RÍ  i   RÎ  R•  (
   R   RD   R÷   R   R  R  RŽ   RÔ  R‘   R�  (   R&   R  R  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_load_default_certs_env­  s    


s   Windows specificc         C   s—   t  j t  j ƒ } | j ƒ  | j ƒ  } t  j t  j ƒ } t j ƒ  �K } t | d <t | d <| j ƒ  | d c d 7<|  j	 | j ƒ  | ƒ Wd  QXd  S(   NR  R  RÎ  i   (
   R   RD   R÷   RÔ  R�  R   R  R  RŽ   R‘   (   R&   R  t   statsR  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt#   test_load_default_certs_env_windows·  s    



c         C   s¹   |  j  | j t j @t j ƒ t d k rC |  j  | j t @t ƒ n  t d k ri |  j  | j t @t ƒ n  t d k r� |  j  | j t @t ƒ n  t d k rµ |  j  | j t @t ƒ n  d  S(   Ni    (   R‘   Rj  R   Rl   R   R   R   R   (   R&   R  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   _assert_context_optionsÅ  s    


c         C   s(  t  j ƒ  } |  j | j t  j ƒ |  j | j t  j ƒ |  j | j ƒ |  j	 | ƒ t
 t ƒ � } | j ƒ  j d ƒ } Wd  QXt  j d t d t d | ƒ } |  j | j t  j ƒ |  j | j t  j ƒ |  j	 | ƒ t  j t  j j ƒ } |  j | j t  j ƒ |  j | j t  j ƒ |  j	 | ƒ d  S(   NR  R  R   R–  (   R   t   create_default_contextR‘   Ra  R
  Rm  Rf   RÃ   t   check_hostnameRÙ  RW   t
   SIGNING_CAR«   R  R  RD  RF  Rd   (   R&   R  RM   R–  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_create_default_contextÔ  s     	c         C   s_  t  j ƒ  } |  j | j t  j ƒ |  j | j t  j ƒ |  j | j ƒ |  j	 | ƒ t  j t  j
 ƒ } |  j | j t  j
 ƒ |  j | j t  j ƒ |  j	 | ƒ t  j t  j
 d t  j d t ƒ} |  j | j t  j
 ƒ |  j | j t  j ƒ |  j | j ƒ |  j	 | ƒ t  j d t  j j ƒ } |  j | j t  j ƒ |  j | j t  j ƒ |  j	 | ƒ d  S(   NRH  RÛ  t   purpose(   R   t   _create_stdlib_contextR‘   Ra  R
  Rm  Rd   t   assertFalseRÛ  RÙ  R÷   Rf   Rj   RÃ   RD  RF  (   R&   R  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test__create_stdlib_contextê  s(    		c         C   s¥   t  j d ƒ } |  j | j | j ƒ | j d t ƒ |  j | j | j ƒ | j d t ƒ |  j | j | j ƒ | j d t ƒ | j ƒ  |  j | j | j ƒ d  S(   NR   t   enable(	   R   t   import_fresh_moduleRË  t   _create_default_https_contextRÚ  t   _https_verify_certificatesRk   t   _create_unverified_contextRj   (   R&   t	   local_ssl(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test__https_verify_certificates  s    



c         C   sq   d } d } i  } t  d | | � d | t j <t  d | | � x+ d	 D]# } | | t j <t  d | | � qF Wd  S(
   Ns  import ssl, sys;             status = "Error: _create_default_https_context does not verify certs"                        if ssl._create_default_https_context is                           ssl._create_unverified_context                      else None;             sys.exit(status)s  import ssl, sys;             status = "Error: _create_default_https_context verifies certs"                        if ssl._create_default_https_context is                           ssl.create_default_context                      else None;             sys.exit(status)s   -cR8   RC   t   1t   enabledRt   (   RC   Ré  Rê  Rt   (   R   R   t   _https_verify_envvar(   R&   t   https_is_verifiedt   https_is_not_verifiedt	   extra_envt   setting(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test__https_verify_envvar  s    c         C   sÚ   t  j t  j ƒ } |  j | j ƒ |  j t ƒ � t | _ Wd  QXt  j | _	 |  j | j ƒ t | _ |  j
 | j ƒ t  j | _	 t | _ |  j
 | j ƒ |  j t ƒ � t  j | _	 Wd  QXt | _ |  j | j ƒ d  S(   N(   R   RD   R÷   Rà  RÛ  Rv   Rê   Rj   Rf   Rm  RÃ   Re   Rd   Rk   (   R&   R  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_check_hostname6  s    			('   R)   R*   RQ   Rb  Rd  Rh  Rl  Rn  RH   R\  R/   Rw  R�  R”  R¤  R²  R¾  RÀ  R   Rg   RÃ  t	   needs_sniRÇ  RÌ  RÏ  RÓ  RÕ  t   skipIfR   RF   RÂ   RÖ  RØ  RÙ  RÝ  Rá  Rè  Rð  Rñ  (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR_  +  s8   			S		:		
				$					t   SSLErrorTestsc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   sz   t  j d d ƒ } |  j t | ƒ d ƒ |  j | j d ƒ t  j d d ƒ } |  j t | ƒ d ƒ |  j | j d ƒ d  S(   Ni   Rt   (   R   RE   R‘   R¾   R$   t   SSLZeroReturnError(   R&   R'   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_strO  s    c         C   s’   t  j t  j ƒ } |  j t  j ƒ � } | j t ƒ Wd  QX|  j | j j	 d ƒ |  j | j j
 d ƒ t | j ƒ } |  j | j d ƒ | ƒ d  S(   Nt   PEMt   NO_START_LINEs"   [PEM: NO_START_LINE] no start line(   R   RD   R÷   Rv   RE   R¨  RŽ   R‘   Rî   t   libraryt   reasonR¾   RÃ   R®   (   R&   R  Rñ   RÈ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_lib_reasonY  s    c         C   s  t  j t  j ƒ } t t j ƒ  ƒ �Ú } | j d ƒ | j d ƒ t j ƒ  } | j | j ƒ  ƒ | j	 t
 ƒ t | j | t
 d t
 ƒƒ �m } |  j t  j ƒ � } | j ƒ  Wd  QXt | j ƒ } |  j | j d ƒ | ƒ |  j | j j t  j ƒ Wd  QXWd  QXd  S(   Ns	   127.0.0.1i    i   t   do_handshake_on_connects%   The operation did not complete (read)(   s	   127.0.0.1i    (   R   RD   R÷   R   R!   t   bindt   listenRë   t   getsocknamet   setblockingRk   RÏ   Rv   t   SSLWantReadErrort   do_handshakeR¾   Rî   RÃ   R®   R‘   R$   t   SSL_ERROR_WANT_READ(   R&   R  RÈ   t   cRñ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_subclassc  s    !(   R)   R*   Rö  Rû  R  (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRô  M  s   	
	
t   NetworkedTestsc           B   s§   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 e
 j e j d k d	 ƒ d
 „  ƒ Z d „  Z d „  Z d „  Z d „  Z e d „  ƒ Z RS(   c      
   C   s+  t  j t ƒ �t j t j t j ƒ d t j ƒ} z- | j t d f ƒ |  j	 i  | j
 ƒ  ƒ Wd  | j ƒ  Xt j t j t j ƒ d t j ƒ} |  j t j d | j t d f ƒ | j ƒ  t j t j t j ƒ d t j d t ƒ} z* | j t d f ƒ |  j | j
 ƒ  ƒ Wd  | j ƒ  XWd  QXd  S(   NRH  i»  s   certificate verify failedt   ca_certs(   R   t   transient_internett   REMOTE_HOSTR   RÏ   R!   R"   Rd   Rë   R‘   t   getpeercertRö   Rf   Ré   RE   t   REMOTE_ROOT_CERTRÃ   (   R&   RÈ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_connectx  s&    
		c      
   C   sˆ   t  j t ƒ �s t j t j t j ƒ d t j d t ƒ} z6 |  j	 d | j
 t d f ƒ ƒ |  j | j ƒ  ƒ Wd  | j ƒ  XWd  QXd  S(   NRH  R  i    i»  (   R   R  R	  R   RÏ   R!   R"   Rf   R  R‘   t
   connect_exRÃ   R
  Rö   (   R&   RÈ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_connect_ex“  s    		c         C   sA  t  j t ƒ �,t j t j t j ƒ d t j d t d t	 ƒ} zé | j
 t	 ƒ | j t d f ƒ } |  j | d t j t j f ƒ t j g  | g g  d ƒ xu t ry | j ƒ  PWq  t j k
 rä t j | g g  g  d ƒ q  t j k
 rt j g  | g g  d ƒ q  Xq  W|  j | j ƒ  ƒ Wd  | j ƒ  XWd  QXd  S(   NRH  R  Rü  i»  i    g      @(   R   R  R	  R   RÏ   R!   R"   Rf   R  Rk   R   R  Rh   R$   t   EINPROGRESSt   EWOULDBLOCKt   selectRj   R  R  t   SSLWantWriteErrorRÃ   R
  Rö   (   R&   RÈ   t   rc(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_non_blocking_connect_exŸ  s(    			
!c         C   s¶   t  j t ƒ �¡ t j t j t j ƒ d t j d t d t	 ƒ} z^ | j
 d ƒ | j t d f ƒ } | d k r� |  j d ƒ n  |  j | t j t j f ƒ Wd  | j ƒ  XWd  QXd  S(   NRH  R  Rü  gH¯¼šò×z>i»  i    s!   REMOTE_HOST responded too quickly(   R   R  R	  R   RÏ   R!   R"   Rf   R  Rk   Râ   R  RY  Rh   R$   t   EAGAINR  Rö   (   R&   RÈ   R  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_timeout_connect_ex¼  s    		 c      
   C   s™   t  j t ƒ �„ t j t j t j ƒ d t j d t ƒ} zG | j	 t d f ƒ } t
 j t
 j t
 j t
 j f } |  j | | ƒ Wd  | j ƒ  XWd  QXd  S(   NRH  R  i¼  (   R   R  R	  R   RÏ   R!   R"   Rf   R  R  R$   t   ECONNREFUSEDt   EHOSTUNREACHt	   ETIMEDOUTR  Rh   Rö   (   R&   RÈ   R  t   errors(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_connect_ex_errorÍ  s    		c      
   C   sy  t  j t ƒ �dt j t j ƒ } | j t j t j ƒ ƒ } | j	 t d f ƒ z |  j
 i  | j ƒ  ƒ Wd  | j ƒ  X| j t j t j ƒ d t ƒ} | j	 t d f ƒ | j ƒ  t j | _ | j t j t j ƒ ƒ } |  j t j d | j	 t d f ƒ | j ƒ  | j t ƒ | j t j t j ƒ ƒ } | j	 t d f ƒ z | j ƒ  } |  j | ƒ Wd  | j ƒ  XWd  QXd  S(   Ni»  R	  s   certificate verify failed(   R   R  R	  R   RD   R
  RÏ   R!   R"   Rë   R‘   R
  Rö   Rf   Rm  Ré   RE   R‘  R  RÃ   (   R&   R  RÈ   Rý   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_connect_with_contextÞ  s.    	

c         C   s(  t  j t ƒ �t j t j ƒ } t j | _ | j d t	 ƒ | j
 t j t j ƒ ƒ } | j t d f ƒ z | j ƒ  } |  j | ƒ Wd  | j ƒ  Xt j t j ƒ } t j | _ | j d t ƒ | j
 t j t j ƒ ƒ } | j t d f ƒ z | j ƒ  } |  j | ƒ Wd  | j ƒ  XWd  QXd  S(   NR   i»  (   R   R  R	  R   RD   R
  Rf   Rm  R‘  R  RÏ   R!   R"   Rë   R
  RÃ   Rö   R“  (   R&   R  RÈ   Rý   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_connect_capathý  s&    c         C   s[  t  t ƒ � } | j ƒ  j d ƒ } Wd  QXt j | ƒ } t j t ƒ �t j	 t j
 ƒ } t j | _ | j d | ƒ t | j t j t j ƒ ƒ ƒ �3 } | j t d f ƒ | j ƒ  } |  j | ƒ Wd  QXt j	 t j
 ƒ } t j | _ | j d | ƒ t | j t j t j ƒ ƒ ƒ �3 } | j t d f ƒ | j ƒ  } |  j | ƒ Wd  QXWd  QXd  S(   NR  R–  i»  (   RW   R  R«   R  R   R¬   R   R  R	  RD   R
  Rf   Rm  R‘  R   RÏ   R!   R"   Rë   R
  RÃ   (   R&   RM   R³   RÒ  R  RÈ   Rý   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_connect_cadata  s$    $$R¥  s*   Can't use a socket as a file under Windowsc         C   sÏ   t  j t ƒ �º t j t j t j ƒ ƒ } | j t d f ƒ | j ƒ  } | j	 ƒ  } | j
 ƒ  t j | d ƒ | j
 ƒ  t j ƒ  |  j t ƒ � } t j | d ƒ Wd  QX|  j | j j t j ƒ Wd  QXd  S(   Ni»  i    (   R   R  R	  R   RÏ   R!   R"   Rë   t   filenot   makefileRö   R   R«   RÉ  RÊ  Rv   t   OSErrorR‘   Rî   R$   t   EBADF(   R&   RÓ   t   fdRM   R'   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_makefile_close0  s    


c      
   C   s  t  j t ƒ �t j t j ƒ } | j t d f ƒ | j t ƒ t j	 | d t j
 d t ƒ} d } xy t rá y | d 7} | j ƒ  PWqi t j k
 r´ t j | g g  g  ƒ qi t j k
 rÝ t j g  | g g  ƒ qi Xqi W| j ƒ  t  j rt j j d | ƒ n  Wd  QXd  S(   Ni»  RH  Rü  i    i   s9   
Needed %d calls to do_handshake() to establish session.
(   R   R  R	  R!   R"   Rë   R   Rk   R   RÏ   Rd   Rj   R  R  R  R  Rö   R   R   R   R   (   R&   RÈ   t   count(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_non_blocking_handshakeD  s(    			


	c            s?   d  ‡  f d † } | t d t ƒ t j r; | d d ƒ n  d  S(   Nc      	      s%  t  j |  ƒ �t j |  | f ƒ } | sE ˆ  j d |  | f ƒ n  y t j |  | f d t ƒ} Wn6 t j k
 rœ } t  j r· t j	 j
 d | ƒ q· n Xˆ  j d | |  | f ƒ t j |  | f d | ƒ} | sò ˆ  j d |  | f ƒ n  t  j rt j	 j
 d |  | | f ƒ n  Wd  QXd  S(   Ns   No server certificate on %s:%s!R  s   %s
s$   Got server certificate %s for %s:%s!s&   
Verified certificate for %s:%s is
%s
(   R   R  R   t   get_server_certificateR°   RŽ   RE   R   R   R   R   (   t   hostt   portRý   R³   RÖ   (   R&   (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   _test_get_server_certificate[  s"    			i»  s   ipv6.google.com(   RÒ   R	  R  R   t   IPV6_ENABLED(   R&   R*  (    (   R&   sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_get_server_certificateZ  s    	c         C   s  t  d f } t j | d ƒ �ù t t j t j t j ƒ d t j d d ƒƒ � } | j	 | ƒ Wd  QXt t j t j t j ƒ d t j d d ƒƒ � } | j	 | ƒ Wd  QX|  j
 t j d ƒ �Q t t j t j ƒ ƒ �2 } t j | d t j d d ƒ} | j	 | ƒ Wd  QXWd  QXWd  QXd  S(	   Ni»  i    RH  t   ciphersRe  Rf  s   No cipher can be selecteds   ^$:,;?*'dorothyx(   R	  R   R  R   R   RÏ   R!   R"   Rd   Rë   Ré   RE   (   R&   t   remoteRÈ   Rð   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRh  u  s    c         C   sÓ   t  j t ƒ �¾ t j t j ƒ } t j | _ | j d t	 ƒ |  j
 | j ƒ  g  ƒ | j t j t j ƒ ƒ } | j t d f ƒ z | j ƒ  } |  j | ƒ Wd  | j ƒ  X|  j
 t | j ƒ  ƒ d ƒ Wd  QXd  S(   NR   i»  i   (   R   R  R	  R   RD   R
  Rf   Rm  R‘  R  R‘   RÑ  RÏ   R!   R"   Rë   R
  RÃ   Rö   R  (   R&   R  RÈ   Rý   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_get_ca_certs_capath…  s    c         C   sÜ   t  j t ƒ �Ç t j t j ƒ } t j t j ƒ } t j t j ƒ } t	 | j
 | ƒ ƒ �u } | j t d f ƒ |  j | j | ƒ |  j | j j | ƒ | | _ |  j | j | ƒ |  j | j j | ƒ Wd  QXWd  QXd  S(   Ni»  (   R   R  R	  R   RD   R÷   R
  R!   R"   R   RÏ   Rë   RË  t   contextt   _sslobj(   R&   t   ctx1t   ctx2RÈ   RÓ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_context_setget•  s    	(   R)   R*   R  R  R  R  R  R  R  R  RH   Ró  R   R
   R$  R&  R,  Rh  R/  Rò  R4  (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR  v  s   								$				(   t   make_https_servert   ThreadedEchoServerc           B   s{   e  Z d  e j f d „  ƒ  YZ d d d d e e e d d d d d „ Z d „  Z	 d „  Z
 d d „ Z d „  Z d „  Z RS(	   t   ConnectionHandlerc           B   sD   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sÂ   A 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         C   sZ   | |  _  t |  _ | |  _ | |  _ |  j j d ƒ d  |  _ t j	 j
 |  ƒ t |  _ d  S(   Ni   (   t   serverRk   t   runningRð   t   addrR   RÒ   t   sslconnt	   threadingt   Threadt   __init__Rj   t   daemon(   R&   R8  t   connsockR:  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR>  µ  s    					c         C   s®  y] |  j  j j |  j d t ƒ|  _ |  j  j j |  j j ƒ  ƒ |  j  j	 j |  j j
 ƒ  ƒ Wn)t j t j t f k
 rˆ} | j t j t j t j f k rù |  j  j j t | ƒ ƒ |  j  j râ t d t |  j ƒ d ƒ n  t |  _ |  j ƒ  t St | t j ƒ r$| j t j k r$‚  n  |  j  j j | ƒ |  j  j rat d t |  j ƒ d ƒ n  t |  _ |  j  j ƒ  |  j ƒ  t Sn"X|  j  j j t j  k r:|  j j! ƒ  } t" j# ré|  j  j rét$ j% j& d t' j( | ƒ d ƒ n  |  j j! t ƒ } t" j# r:|  j  j r:t$ j% j& d t t) | ƒ ƒ d ƒ q:n  |  j j* ƒ  } t" j# r¦|  j  j r¦t$ j% j& d t | ƒ d ƒ t$ j% j& d	 t |  j j ƒ  ƒ d ƒ n  t Sd  S(
   NRç   s'   
 server:  bad connection attempt from s   :
s    client cert is s   
s    cert binary is s    bytes
s"    server: connection cipher is now s"    server: selected protocol is now (+   R8  R0  RÏ   Rð   Rj   R;  t   selected_npn_protocolst   appendt   selected_npn_protocolt   selected_alpn_protocolst   selected_alpn_protocolR   RE   R!   R×   R!  R$   t
   ECONNRESETt   EPIPEt	   ESHUTDOWNt   conn_errorsR¾   t   chattyR   t   reprR:  Rk   R9  Rö   R'  t   stopRm  Rf   R
  R   R   R   R   R   R�   R�   R  t   cipher(   R&   R'   Rý   t   cert_binaryRM  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt	   wrap_conn¿  sH     !	
%	
$*	!c         C   s*   |  j  r |  j  j ƒ  S|  j j d ƒ Sd  S(   Ni   (   R;  R«   Rð   RØ   (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR«   ù  s    	c         C   s-   |  j  r |  j  j | ƒ S|  j j | ƒ Sd  S(   N(   R;  R   Rð   RÝ   (   R&   R%  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR   ÿ  s    	c         C   s*   |  j  r |  j  j ƒ  n |  j j ƒ  d  S(   N(   R;  Rö   Rð   (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRö     s    	c         C   sÑ  t  |  _ |  j j s( |  j ƒ  s( d  Sn  x¢|  j rÌyE|  j ƒ  } | j ƒ  } | sk t |  _ |  j ƒ  n| d k r­ t	 j
 rŸ |  j j rŸ t j j d ƒ n  |  j ƒ  d  S|  j j r| d k rt	 j
 rí |  j j rí t j j d ƒ n  |  j d ƒ |  j ƒ  sxd  Snk|  j j r©|  j r©| d k r©t	 j
 rV|  j j rVt j j d ƒ n  |  j d ƒ |  j j ƒ  |  _ d  |  _ t	 j
 rx|  j j rxt j j d ƒ qxnÏ | d	 k rt	 j
 rÝ|  j j rÝt j j d
 ƒ n  |  j j d ƒ } |  j t | ƒ j d ƒ d ƒ nf t	 j
 re|  j j re|  j r6d p9d } t j j d | | | j ƒ  | f ƒ n  |  j | j ƒ  ƒ Wq+ t j k
 rÈ|  j j r¥t d ƒ n  |  j ƒ  t |  _ |  j j ƒ  q+ Xq+ Wd  S(   Nt   overs"    server: client closed connection
t   STARTTLSs2    server: read STARTTLS from client, sending OK...
s   OK
t   ENDTLSs0    server: read ENDTLS from client, sending OK...
s*    server: connection is now unencrypted...
s   CB tls-uniques@    server: read CB tls-unique from client, sending our CB data...
s
   tls-uniques   us-asciis   
t	   encryptedt   unencrypteds/    server: read %r (%s), sending back %r (%s)...
s   Test server failure:
(   Rj   R9  R8  t   starttls_serverRO  R«   t   stripRk   Rö   R   R   t   connectionchattyR   R   R   R;  t   unwrapRð   RÒ   R  RK  R  RX  R   RE   RJ  R   RL  (   R&   t   msgt   strippedt   datat   ctype(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   run  sb    		
	#	
	(	   R)   R*   t   __doc__R>  RO  R«   R   Rö   R]  (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR7  ¯  s   	
	:			c         C   s`  | r | |  _  nÅ t j | d  k	 r* | n t j ƒ |  _  | d  k	 rK | n t j |  j  _ | rs |  j  j | ƒ n  | rŒ |  j  j | ƒ n  | r¥ |  j  j	 | ƒ n  |	 r¾ |  j  j
 |	 ƒ n  |
 r× |  j  j |
 ƒ n  | |  _ | |  _ | |  _ t j ƒ  |  _ t j |  j ƒ |  _ d  |  _ t |  _ g  |  _ g  |  _ g  |  _ t j j |  ƒ t |  _ d  S(   N(   R0  R   RD   RÒ   t   PROTOCOL_TLSRd   Rm  R‘  R‡  t   set_npn_protocolst   set_alpn_protocolsRg  RJ  RW  RU  R!   Rð   R   t	   bind_portR)  t   flagRk   t   activeRA  RD  RI  R<  R=  R>  Rj   R?  (   R&   t   certificateRó   t   certreqst   cacertsRJ  RW  RU  t   npn_protocolst   alpn_protocolsR-  R0  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR>  B  s:    								c         C   s$   |  j  t j ƒ  ƒ |  j j ƒ  |  S(   N(   t   startR<  t   EventRc  t   wait(   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt	   __enter__f  s    c         G   s   |  j  ƒ  |  j ƒ  d  S(   N(   RL  R   (   R&   RJ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   __exit__k  s    
c         C   s   | |  _  t j j |  ƒ d  S(   N(   Rc  R<  R=  Rj  (   R&   Rc  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRj  o  s    	c         C   s	  |  j  j d ƒ |  j  j d ƒ t |  _ |  j rB |  j j ƒ  n  x³ |  j r÷ yu |  j  j ƒ  \ } } t j	 r™ |  j
 r™ t j j d t | ƒ d ƒ n  |  j |  | | ƒ } | j ƒ  | j ƒ  WqE t j k
 rÙ qE t k
 ró |  j ƒ  qE XqE W|  j  j ƒ  d  S(   Ngš™™™™™©?i   s    server:  new connection from s   
(   Rð   Râ   Rþ  Rj   Rd  Rc  R#  R¶  R   R   RJ  R   R   R   RK  R7  Rj  R   R!   Rä   t   KeyboardInterruptRL  Rö   (   R&   t   newconnt   connaddrt   handler(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR]  s  s&    			
c         C   s   t  |  _ d  S(   N(   Rk   Rd  (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRL  ‰  s    N(   R)   R*   R<  R=  R7  RÒ   Rj   Rk   R>  Rm  Rn  Rj  R]  RL  (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR6  ­  s   “	 			t   AsyncoreEchoServerc           B   sc   e  Z d  e j f d „  ƒ  YZ d „  Z d „  Z d „  Z d „  Z d	 d „ Z
 d „  Z d „  Z RS(
   t
   EchoServerc           B   s<   e  Z d  e j f d „  ƒ  YZ d „  Z d „  Z d „  Z RS(   R7  c           B   s>   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   sQ   t  j | d t d | d t ƒ|  _ t j j |  |  j ƒ t |  _ |  j	 ƒ  d  S(   NRç   Rè   Rü  (
   R   RÏ   Rj   Rk   R!   t   asyncoret   dispatcher_with_sendR>  t   _ssl_acceptingt   _do_ssl_handshake(   R&   t   connRè   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR>  ’  s    	c         C   sB   t  |  j t j ƒ r> x& |  j j ƒ  d k r: |  j ƒ  q Wn  t S(   Ni    (   R'  R!   R   t	   SSLSockett   pendingt   handle_read_eventRj   (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   readableš  s    c         C   s¤   y |  j  j ƒ  Wnƒ t j t j f k
 r1 d  St j k
 rK |  j ƒ  St j k
 ra ‚  n? t  j k
 r– } | j	 d t
 j k r  |  j ƒ  Sn
 Xt |  _ d  S(   Ni    (   R!   R  R   R  R  t   SSLEOFErrort   handle_closeRE   R×   RJ   R$   t   ECONNABORTEDRk   Rw  (   R&   Ra   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRx     s    
c         C   su   |  j  r |  j ƒ  n[ |  j d ƒ } t j rK t j j d t | ƒ ƒ n  | s^ |  j	 ƒ  n |  j
 | j ƒ  ƒ d  S(   Ni   s    server:  read %s from client
(   Rw  Rx  RØ   R   R   R   R   R   RK  Rö   RÝ   RX  (   R&   R[  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   handle_read¯  s    		c         C   s1   |  j  ƒ  t j r- t j j d |  j ƒ n  d  S(   Ns    server:  closed connection %s
(   Rö   R   R   R   R   R   R!   (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR  »  s    
	c         C   s   ‚  d  S(   N(    (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR   À  s    (   R)   R*   R>  R}  Rx  R�  R  R   (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR7  �  s   					c         C   sZ   | |  _  t j t j t j ƒ } t j | d ƒ |  _ t j j	 |  | ƒ |  j
 d ƒ d  S(   NRC   i   (   Rè   R!   R"   t   SOCK_STREAMR   Rb  R)  Ru  t
   dispatcherR>  Rþ  (   R&   Rè   Rð   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR>  Ã  s
    	c         C   sI   |  j  ƒ  \ } } t j r2 t j j d | ƒ n  |  j | |  j ƒ d  S(   Ns$    server:  new connection from %s:%s
(   R¶  R   R   R   R   R   R7  Rè   (   R&   t   sock_objR:  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   handle_acceptÊ  s    	c         C   s   ‚  d  S(   N(    (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR   Ð  s    (   R)   R*   Ru  Rv  R7  R>  R…  R   (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRt  Ž  s   3		c         C   sP   d  |  _ t |  _ |  j | ƒ |  _ |  j j |  _ t j j	 |  ƒ t
 |  _ d  S(   N(   RÒ   Rc  Rk   Rd  Rt  R8  R)  R<  R=  R>  Rj   R?  (   R&   Rè   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR>  Ó  s    		c         C   s   d |  j  j |  j f S(   Ns   <%s %s>(   t	   __class__R)   R8  (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   __str__Û  s    c         C   s$   |  j  t j ƒ  ƒ |  j j ƒ  |  S(   N(   Rj  R<  Rk  Rc  Rl  (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRm  Þ  s    c         G   s|   t  j r t j j d ƒ n  |  j ƒ  t  j rB t j j d ƒ n  |  j ƒ  t  j rh t j j d ƒ n  t j d t	 ƒ d  S(   Ns    cleanup: stopping server.
s!    cleanup: joining server thread.
s    cleanup: successfully joined.
t
   ignore_all(
   R   R   R   R   R   RL  R   Ru  t	   close_allRj   (   R&   RJ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRn  ã  s    	
	
	c         C   s   | |  _  t j j |  ƒ d  S(   N(   Rc  R<  R=  Rj  (   R&   Rc  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRj  ï  s    	c         C   sQ   t  |  _ |  j r" |  j j ƒ  n  x( |  j rL y t j d ƒ Wq% q% Xq% Wd  S(   Ni   (   Rj   Rd  Rc  R#  Ru  t   loop(   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR]  ó  s    		c         C   s   t  |  _ |  j j ƒ  d  S(   N(   Rk   Rd  R8  Rö   (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRL  ý  s    	N(   R)   R*   Ru  Rƒ  Rt  R>  R‡  Rm  Rn  RÒ   Rj  R]  RL  (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRs  Œ  s   E					
s   FOO
c         C   sÿ  i  } t  d | d | d t ƒ } | �Òt |  j t j ƒ  d | ƒƒ ��} | j t | j f ƒ xÙ | t | ƒ t	 | ƒ g D]¼ }	 | r­ t
 j r­ t j j d | ƒ q­ n  | j |	 ƒ | j ƒ  }
 | rï t
 j rï t j j d |
 ƒ qï n  |
 | j ƒ  k r~ t d |
 d  t |
 ƒ | d  j ƒ  t | ƒ f ƒ ‚ q~ q~ W| j d	 ƒ | rpt
 j rpt j j d
 ƒ qpn  | j i | j ƒ  d 6| j ƒ  d 6| j ƒ  d 6| j ƒ  d 6| j ƒ  d 6| j ƒ  d 6ƒ | j ƒ  Wd QX| j | d <| j | d <Wd QX| S(   sc   
        Launch a server, connect a client to it and try various reads
        and writes.
        R0  RJ  RW  R	  s    client:  sending %r...
s    client:  read %r
s4   bad data <<%r>> (%d) received; expected <<%r>> (%d)
i   s   over
s    client:  closing connection.
t   compressionRM  t   peercertt   client_alpn_protocolt   client_npn_protocolR—   Nt   server_alpn_protocolst   server_npn_protocols(   R6  Rk   R   RÏ   R!   Rë   Rì   R)  RÚ   t
   memoryviewR   R   R   R   R   R«   RX  t   AssertionErrorR  R(  R‹  RM  R
  RE  RC  R—   Rö   RD  RA  (   t   client_contextt   server_contextt   indataRJ  RW  t   sni_nameR×  R8  RÈ   t   argt   outdata(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   server_params_test  sL    	"			'		c         C   s  | d k r t j } n  i d t j 6d t j 6d t j 6| } t j r� | rU d pX d } t j j	 | t j
 | ƒ t j
 |  ƒ | f ƒ n  t j | ƒ } | j | O_ t j |  ƒ }	 |	 j | O_ | j t j k rë | j d ƒ n  x7 | |	 f D]) }
 | |
 _ |
 j t ƒ |
 j t ƒ qø Wy t | |	 d t d t ƒ} WnS t j k
 rf| r‚  qnž t j k
 r™} | s�| j t j k r‚  qnk X| sËt d	 t j
 | ƒ t j
 |  ƒ f ƒ ‚ n9 | t k	 r| | d
 k rt d | | d
 f ƒ ‚ n  d S(   sT  
        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.
        Rd   Re   Rf   s    %s->%s %s
s    {%s->%s} %s
Re  RJ  RW  s5   Client protocol %s succeeded with server protocol %s!R—   s%   version mismatch: expected %r, got %rN(   RÒ   R   Rd   Re   Rf   R   R   R   R   R   t   get_protocol_nameRD   Rj  Ra  R
  Rg  Rm  R‡  RŽ   R‘  R™  Rk   RE   R!   R×   R$   RF  R’  Rj   (   t   server_protocolt   client_protocolt   expect_successt	   certsreqst   server_optionst   client_optionst   certtypet	   formatstrR“  R”  R  R×  R'   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   try_protocol_combo/  sR    	


			
t   ThreadedTestsc           B   sç  e  Z e d  „  ƒ Z d „  Z e j e ƒ  d ƒ d „  ƒ Z d „  Z	 d „  Z
 d „  Z e e j e e d ƒ d ƒ d	 „  ƒ ƒ Z e e d
 „  ƒ ƒ Z e e j e e d ƒ d ƒ d „  ƒ ƒ Z e d „  ƒ Z e e j e e d ƒ d ƒ e d „  ƒ ƒ ƒ Z e e j e e d ƒ d ƒ d „  ƒ ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e j e j  d  ƒ d! „  ƒ Z! e j e j" d" ƒ d# „  ƒ Z# e j d$ e j$ k d% ƒ d& „  ƒ Z% d' „  Z& e j e e d( ƒ d) ƒ d* „  ƒ Z' d+ „  Z( d, „  Z) e j e j* d- ƒ d. „  ƒ Z+ e j e j* d/ ƒ d0 „  ƒ Z, d1 „  Z- e j e j. d2 ƒ d3 „  ƒ Z/ d4 „  Z0 d5 „  Z1 e2 d6 „  ƒ Z3 e2 d7 „  ƒ Z4 e2 d8 „  ƒ Z5 e2 d9 „  ƒ Z6 d: „  Z7 RS(;   c         C   sf   t  j r t j j d ƒ n  xC t D]; } t j | ƒ } | j t	 ƒ t
 | | d t d t ƒq# Wd S(   s2   Basic test of an SSL client connecting to a servers   
RJ  RW  N(   R   R   R   R   R   R`  R   RD   R‡  RŽ   R™  Rj   (   R&   Ra  R0  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt	   test_echom  s    	c      	   C   sí  t  j r t j j d ƒ n  t j t j ƒ } t j | _	 | j
 t ƒ | j t ƒ t d | d t ƒ } | �x| j t j ƒ  d t ƒ} | j t | j f ƒ |  j t ƒ � | j ƒ  Wd  QX| j ƒ  | j ƒ  } |  j | d ƒ | j ƒ  } t  j r:t j j t j | ƒ d ƒ t j j d t | ƒ d ƒ n  d | k rc|  j d	 t j | ƒ ƒ n  d | d k rƒ|  j d ƒ n  |  j d | ƒ |  j d | ƒ t j | d ƒ } t j | d ƒ } |  j  | | ƒ | j! ƒ  Wd  QXd  S(   Ns   
R0  RJ  Rü  s   Can't get peer certificate.s   Connection cipher is s   .
R†   s$   No subject field in certificate: %s.R   s   Python Software Foundationsk   Missing or invalid 'organizationName' field in certificate subject; should be 'Python Software Foundation'.Rƒ   R‚   (   R   s   Python Software Foundation(   (   R   s   Python Software Foundation("   R   R   R   R   R   R   RD   R
  Rf   Rm  R‘  RŽ   R‡  R6  Rk   RÏ   R!   Rë   Rì   R)  Rv   Rê   R
  R  RÃ   RM  R�   R�   R¾   R°   Rh   RL  RÀ   Rö   (   R&   R0  R8  RÈ   Rý   RM  t   beforet   after(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_getpeercertx  sB    		
	!	
s!   verify_flags need OpenSSL > 0.9.8c         C   s  t  j r t j j d ƒ n  t j t j ƒ } | j t	 ƒ t j t j ƒ } t j
 | _ | j t ƒ t t d d ƒ } |  j | j t j | Bƒ t d | d t ƒ } | �[ t | j t j ƒ  ƒ ƒ �9 } | j t | j f ƒ | j ƒ  } |  j | d ƒ Wd  QXWd  QX| j t j O_ t d | d t ƒ } | �[ t | j t j ƒ  ƒ ƒ �9 } |  j t j d ƒ � | j t | j f ƒ Wd  QXWd  QXWd  QX| j t ƒ t d | d t ƒ } | �[ t | j t j ƒ  ƒ ƒ �9 } | j t | j f ƒ | j ƒ  } |  j | d ƒ Wd  QXWd  QXd  S(   Ns   
Ro  i    R0  RJ  s   Can't get peer certificate.s   certificate verify failed(    R   R   R   R   R   R   RD   R÷   R‡  t   SIGNED_CERTFILERf   Rm  R‘  RÜ  Rp  R‘   Rq  Rr  R6  Rj   R   RÏ   R!   Rë   Rì   R)  R
  RÃ   Rs  Ré   RE   t   CRLFILE(   R&   R”  R0  Rv  R8  RÈ   Rý   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_crl_checkž  s:    	
(c         C   sÒ  t  j r t j j d ƒ n  t j t j ƒ } | j t	 ƒ t j t j ƒ } t j
 | _ t | _ | j t ƒ t d | d t ƒ } | �a t | j t j ƒ  d d ƒƒ �9 } | j t | j f ƒ | j ƒ  } |  j | d ƒ Wd  QXWd  QXt d | d t ƒ } | �a t | j t j ƒ  d d ƒƒ �9 } |  j t j d ƒ � | j t | j f ƒ Wd  QXWd  QXWd  QXt d | d t ƒ } | �F t t j ƒ  ƒ �- } |  j t d	 ƒ � | j | ƒ Wd  QXWd  QXWd  QXd  S(
   Ns   
R0  RJ  R	  R�   s   Can't get peer certificate.t   invalids.   hostname 'invalid' doesn't match u?'localhost's'   check_hostname requires server_hostname(   R   R   R   R   R   R   RD   R÷   R‡  R©  Rf   Rm  Rj   RÛ  R‘  RÜ  R6  R   RÏ   R!   Rë   Rì   R)  R
  RÃ   Ré   R   Rê   (   R&   R”  R0  R8  RÈ   Rý   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRñ  É  s8    		
(	
c         C   sW  t  j j t  j j t ƒ p! t  j d ƒ } t t d t j	 d t
 d t d t ƒ} | �ú t t j ƒ  ƒ �á } t t j | d | d t j ƒƒ �´ } y | j t | j f ƒ Wnƒ t j k
 ræ } t j rAt j j d | ƒ qAn[ t j k
 r3} | j t j k r‚  n  t j rAt j j d	 | ƒ qAn X|  j d
 ƒ Wd QXWd QXWd QXd S(   sÓ   Connecting 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.
            s   keycert.pemRf  Rg  RJ  RW  Rè   Ró   s   
SSLError is %r
s   
socket.error is %r
s'   Use of invalid cert should have failed!N(   R   R   R   R   R	   Rô   R6  R©  R   Rf   RÜ  Rk   R   R!   RÏ   R÷   Rë   Rì   R)  RE   R   R   R   R   R   R×   R$   RF  R°   (   R&   Rè   R8  Rð   RÈ   R'   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_wrong_certï  s,    !						c            sœ   t  j ƒ  ‰ t  j ƒ  ‰  t j ƒ  ‰ t j ˆ t ƒ ‰ ‡  ‡ ‡ f d †  } ‡  ‡ ‡ ‡ f d †  } t  j d | ƒ } | j ƒ  z | ƒ  Wd | j ƒ  Xd S(   s|   A brutal shutdown of an SSL server should raise an OSError
            in the client when attempting handshake.
            c             sK   ˆ j  d ƒ ˆ j ƒ  ˆ j ƒ  \ }  } |  j ƒ  ˆ j ƒ  ˆ  j ƒ  d  S(   Ni   (   Rþ  R#  R¶  Rö   (   t   newsockR:  (   t   listener_gonet   listener_readyRÈ   (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   listener	  s    


c       	      s}   ˆ j  ƒ  t t j ƒ  ƒ �[ }  |  j t ˆ f ƒ ˆ  j  ƒ  y t j |  ƒ } Wn t j k
 re n Xˆ j d ƒ Wd  QXd  S(   Ns2   connecting to closed SSL socket should have failed(	   Rl  R   R!   Rë   Rì   R   RÏ   R×   R°   (   R  t   ssl_sock(   R¯  R°  R)  R&   (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt	   connector&	  s    

t   targetN(	   R<  Rk  R!   R   Rb  Rì   R=  Rj  R   (   R&   R±  R³  RÇ   (    (   R¯  R°  R)  RÈ   R&   sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_rude_shutdown	  s    
RA   s)   OpenSSL is compiled without SSLv2 supportc         C   s  t  j r t j j d ƒ n  t t j t j t ƒ t t j t j t t j	 ƒ t t j t j t t j
 ƒ t t j t j t ƒ t t j t j t ƒ t t j t j t ƒ t ƒ  r× t t j t j t d t j ƒn  t t j t j t d t j ƒt t j t j t d t j ƒd S(   s9   Connecting to an SSLv2 server with various client optionss   
R   N(   R   R   R   R   R   R£  R   RA   Rj   Re   Rf   R
  Rk   t   PROTOCOL_SSLv3R÷   R.   Rl   Rm   Rn   (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_protocol_sslv29	  s    		
c         C   s!  t  j r t j j d ƒ n  t t d ƒ r‡ y t t j t j	 t
 ƒ Wq‡ t j k
 rƒ } t  j r„ t j j d t | ƒ ƒ q„ q‡ Xn  t t d ƒ r¯ t t j t j t ƒ n  t t j t j t
 ƒ t t j t j d ƒ t t d ƒ r	t t j t j t t j ƒ n  t t j t j t
 t j ƒ t t j t j d t j ƒ t t d ƒ rot t j t j t t j ƒ n  t t j t j t
 t j ƒ t t j t j d t j ƒ t t d ƒ rØt t j t j t d t j ƒn  t t j t j t
 d t j t j Bƒt t j t j t d t j ƒd S(   s:   Connecting to an SSLv23 server with various client optionss   
RA   s;    SSL2 client to SSL23 server test unexpectedly failed:
 %s
R¶  RT   RŸ  N(   R   R   R   R   R   RN   R   R£  R
  RA   Rj   R!   R×   R¾   R¶  Rk   R÷   Re   Rf   Rm   Rl   Rn   (   R&   RÖ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_protocol_sslv23P	  s:    			R¶  s)   OpenSSL is compiled without SSLv3 supportc         C   sö   t  j r t j j d ƒ n  t t j t j d ƒ t t j t j d t j ƒ t t j t j d t j	 ƒ t
 t d ƒ r’ t t j t j t ƒ n  t t j t j t d t j ƒt t j t j t ƒ t ƒ  rò t t j t j t d t j ƒn  d S(   s9   Connecting to an SSLv3 server with various client optionss   
t   SSLv3RA   R   N(   R   R   R   R   R   R£  R   R¶  Re   Rf   RN   RA   Rk   R
  Rm   R÷   R.   Rl   (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_protocol_sslv3y	  s    	
	c         C   sÝ   t  j r t j j d ƒ n  t t j t j d ƒ t t j t j d t j ƒ t t j t j d t j	 ƒ t
 t d ƒ r’ t t j t j t ƒ n  t
 t d ƒ rº t t j t j t ƒ n  t t j t j t d t j ƒd S(   s8   Connecting to a TLSv1 server with various client optionss   
RT   RA   R¶  R   N(   R   R   R   R   R   R£  R   R÷   Re   Rf   RN   RA   Rk   R¶  R
  Rn   (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_protocol_tlsv1�	  s    	t   PROTOCOL_TLSv1_1s   TLS version 1.1 not supported.c         C   sç   t  j r t j j d ƒ n  t t j t j d ƒ t t d ƒ rZ t t j t j	 t
 ƒ n  t t d ƒ r‚ t t j t j t
 ƒ n  t t j t j t
 d t j ƒt t j t j d ƒ t t j t j t
 ƒ t t j t j t
 ƒ d S(   sn   Connecting to a TLSv1.1 server with various client options.
               Testing against older TLS versions.s   
s   TLSv1.1RA   R¶  R   N(   R   R   R   R   R   R£  R   R¼  RN   RA   Rk   R¶  R
  Rp   R÷   (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_protocol_tlsv1_1œ	  s    	
t   PROTOCOL_TLSv1_2s   TLS version 1.2 not supported.c      	   C   s3  t  j r t j j d ƒ n  t t j t j d d t j t j	 Bd t j t j	 Bƒt
 t d ƒ rz t t j t j t ƒ n  t
 t d ƒ r¢ t t j t j t ƒ n  t t j t j t d t j ƒt t j t j d ƒ t t j t j t ƒ t t j t j t ƒ t t j t j t ƒ t t j t j t ƒ d S(   sn   Connecting to a TLSv1.2 server with various client options.
               Testing against older TLS versions.s   
s   TLSv1.2RŸ  R   RA   R¶  N(   R   R   R   R   R   R£  R   R¾  Rm   Rl   RN   RA   Rk   R¶  R
  Rq   R÷   R¼  (   R&   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_protocol_tlsv1_2²	  s     	
c   	   
   C   s8  d } t  t d	 t j d
 t d t d t ƒ} t } | �ùt j ƒ  } | j d ƒ | j t	 | j
 f ƒ t j r… t j j d ƒ n  xJ| D]B} t j r² t j j d | ƒ n  | rÔ | j | ƒ | j ƒ  } n | j | ƒ | j d ƒ } | j ƒ  j ƒ  } | d k r^| j d ƒ r^t j r=t j j d | ƒ n  t j | d	 t j ƒ} t } qŒ | d k r®| j d ƒ r®t j r™t j j d | ƒ n  | j ƒ  } t } qŒ t j rŒ t j j d | ƒ qŒ qŒ Wt j rît j j d ƒ n  | r| j d ƒ n | j d ƒ | r$| j ƒ  n
 | j ƒ  Wd QXd S(   s6   Switching from clear text to encrypted and back again.s   msg 1s   MSG 2RQ  s   MSG 3s   msg 4RR  s   msg 5s   msg 6Ró   RU  RJ  RW  i   s   
s    client:  sending %r...
i   Rÿ   s/    client:  read %r from server, starting TLS...
s-    client:  read %r from server, ending TLS...
s    client:  read %r from server
s    client:  closing connection.
s   over
N(   s   msg 1s   MSG 2RQ  s   MSG 3s   msg 4RR  s   msg 5s   msg 6(   R6  RŽ   R   R÷   Rj   Rk   R!   R   Rë   Rì   R)  R   R   R   R   R   R«   RÝ   RØ   RV  RX  R®   RÏ   RX  Rö   (	   R&   t   msgsR8  t   wrappedRÈ   R•  Ry  R˜  RY  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_starttlsÊ	  s`    															c         C   s9  t  |  d t ƒ} t j r. t j j d ƒ n  t t d ƒ � } | j ƒ  } Wd QXd } d | j	 t
 j j t ƒ d f } t j d t ƒ } t j | d	 | ƒ} zu | j ƒ  j d
 ƒ } | rt | ƒ d k r| j t | ƒ ƒ } t j rt j j d t | ƒ | f ƒ qn  Wd | j ƒ  X|  j | | ƒ d S(   s:   Using a SocketServer to create and manage SSL connections.Rè   s   
t   rbNRC   s   https://localhost:%d/%si   R  R0  s   content-lengthi    s/    client: read %d bytes from remote server '%s'
(   R5  RŽ   R   R   R   R   R   RW   R«   R)  R   R   t   splitR   RÚ  t   urllib2t   urlopent   infot	   getheaderR»   R  Rö   R‘   (   R&   R8  RM   R´   R¶   t   urlR0  t   dlen(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_socketserver
  s(    	 		c         C   s^  t  j r t j j d ƒ n  d } t t ƒ } | �$t j t	 j	 ƒ  ƒ } | j
 d | j f ƒ t  j r€ t j j d | ƒ n  | j | ƒ | j ƒ  } t  j r¹ t j j d | ƒ n  | | j ƒ  k r|  j d | d  t | ƒ | d  j ƒ  t | ƒ f ƒ n  | j d ƒ t  j r.t j j d	 ƒ n  | j ƒ  t  j rTt j j d
 ƒ n  Wd QXd S(   s'   Check the example asyncore integration.s   
s   FOO
s	   127.0.0.1s    client:  sending %r...
s    client:  read %r
s4   bad data <<%r>> (%d) received; expected <<%r>> (%d)
i   s   over
s    client:  closing connection.
s    client:  connection closed.
N(   R   R   R   R   R   Rs  RŽ   R   RÏ   R!   Rë   R)  R«   RX  R°   R  Rö   (   R&   R•  R8  RÈ   R˜  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_asyncore_server
  s2    				!	
	c            s=  t  j r t j j d ƒ n  t t d t j d t j	 d t d t
 d t ƒ} | �åt j t j ƒ  d t d t d	 t d
 t j d t j	 ƒ‰  ˆ  j t | j f ƒ ‡  f d †  } ‡  f d †  } d ˆ  j t
 g  f d ˆ  j t d g f d ˆ  j t
 g  f g } d ˆ  j t
 g  f d ˆ  j t d g f d | t
 g  f d | t g  f g } d } x| D]\ } } }	 }
 | | j d ƒ } yw | | |
 Œ ˆ  j ƒ  } | | j ƒ  k rò|  j d j d | d | d  d t | ƒ d | d  d t | ƒ ƒ ƒ n  WqWt k
 ra} |	 r'|  j d j d | ƒ ƒ n  t | ƒ j | ƒ sb|  j d j d | d  | ƒ ƒ qbqWXqWWx| D]\ } } }	 }
 | | j d ƒ } yw ˆ  j | ƒ | |
 Œ  } | | j ƒ  k r|  j d! j d | d | d  d t | ƒ d | d  d t | ƒ ƒ ƒ n  Wqmt k
 r�} |	 r=|  j d" j d | ƒ ƒ n  t | ƒ j | ƒ st|  j d j d | d  | ƒ ƒ n  ˆ  j ƒ  qmXqmWd# } ˆ  j | ƒ t t | ƒ ƒ } |  j  ˆ  j d$ | ƒ t | ƒ ƒ |  j  | | ƒ |  j! t" ˆ  j# ƒ ˆ  j d% ƒ |  j! t ˆ  j d$ ƒ |  j! t ˆ  j d$ ƒ ˆ  j$ ƒ  Wd& QXd& S('   s    Test recv(), send() and friends.s   
Rf  Ró   Rg  RJ  RW  Rç   Rè   R  RH  c             s'   t  d d ƒ }  ˆ  j |  ƒ } |  |  S(   Ns    id   (   RÚ   RÙ   (   t   bR%  (   RÈ   (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt
   _recv_intoO
  s    c             s-   t  d d ƒ }  ˆ  j |  ƒ \ } } |  |  S(   Ns    id   (   RÚ   RÜ   (   RÍ  R%  R:  (   RÈ   (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   _recvfrom_intoT
  s    RÝ   RÞ   s   some.addresst   sendallRØ   RÛ   RÙ   RÜ   u   PREFIX_R  sp   While sending with <<{name:s}>> bad data <<{outdata:r}>> ({nout:d}) received; expected <<{indata:r}>> ({nin:d})
R
   R˜  i   t   noutR•  t   nins>   Failed to send with method <<{name:s}>>; expected to succeed.
sF   Method <<{name:s}>> failed with unexpected exception message: {exp:s}
t   expsr   While receiving with <<{name:s}>> bad data <<{outdata:r}>> ({nout:d}) received; expected <<{indata:r}>> ({nin:d})
sA   Failed to receive with method <<{name:s}>>; expected to succeed.
R[  iÿÿÿÿs   over
N(%   R   R   R   R   R   R6  RŽ   R   Rd   R÷   Rj   Rk   RÏ   R!   Rë   Rì   R)  RÝ   RÞ   RÐ  RØ   RÛ   R  R«   RX  R°   RÄ   R  Rê   R¾   R®   RÚ   R‘   Rv   Rß   Rà   Rö   (   R&   R8  RÎ  RÏ  t   send_methodst   recv_methodst   data_prefixt	   meth_namet	   send_methR�  RJ   R•  R˜  R'   t	   recv_methR[  t   buffer(    (   RÈ   sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_recv_send;
  sš    							!			!		"c         C   s  t  t ƒ } | j ƒ  |  j | j d  d  ƒ t j t | j	 f ƒ } |  j | j
 ƒ t j | d t ƒ} |  j | j
 ƒ | j d ƒ |  j | j d ƒ d ƒ |  j | j d ƒ d ƒ |  j | j ƒ  d ƒ | j t ƒ |  j | j d ƒ d ƒ |  j | j t ƒ  ƒ d ƒ d  S(   Nt   suppress_ragged_eofsR[  i    RC   (   R6  RŽ   Rm  Rõ   Rn  RÒ   R!   t   create_connectionRì   R)  Rö   R   RÏ   Rk   RÝ   R‘   RØ   R«   R   RÙ   RÚ   (   R&   R8  RÈ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_recv_zero²
  s    
c            s\  t  j  t  j ƒ ‰ d } t j ˆ ƒ } t j ƒ  ‰ t ‰  ‡  ‡ ‡ f d †  } t j d | ƒ } | j ƒ  ˆ j	 ƒ  zÆ zR t  j  t  j ƒ } | j
 d ƒ | j | | f ƒ |  j t j d t j | ƒ Wd  | j ƒ  XzT t  j  t  j ƒ } t j | ƒ } | j
 d ƒ |  j t j d | j | | f ƒ Wd  | j ƒ  XWd  t ‰  | j ƒ  ˆ j ƒ  Xd  S(   Ns	   127.0.0.1c             s“   ˆ j  d ƒ ˆ j ƒ  g  }  xT ˆ  ss t j ˆ g g  g  d ƒ \ } } } ˆ | k r  |  j ˆ j ƒ  d ƒ q  q  Wx |  D] } | j ƒ  q{ Wd  S(   Ni   gš™™™™™¹?i    (   Rþ  R#  R  RB  R¶  Rö   (   t   connsRS   t   wR'   Rð   (   t   finishR8  t   started(    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   serveÎ
  s    
	$R´  gš™™™™™É?s	   timed out(   R!   R"   R   Rb  R<  Rk  Rk   R=  Rj  Rl  Râ   Rë   Ré   R   RE   RÏ   Rö   Rj   R   (   R&   R(  R)  Rã  RÇ   R  (    (   Rá  R8  Râ  sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_handshake_timeoutÆ
  s6    


c            sv  t  j t  j ƒ } t  j | _ | j t ƒ | j t ƒ t j t j	 ƒ ‰ d } t
 j ˆ ƒ } | j ˆ d t ƒ‰ t j ƒ  ‰  d  g ‰ d  g ‰ ‡  ‡ ‡ ‡ f d †  } t j d | ƒ } | j ƒ  ˆ  j ƒ  | j t j ƒ  ƒ } | j | | f ƒ | j d ƒ | j ƒ  | j ƒ  } | j ƒ  | j ƒ  ˆ d j ƒ  ˆ j ƒ  |  j ˆ d t  j ƒ |  j ˆ d | ƒ d  S(   Ns	   127.0.0.1Rç   c              sS   ˆ j  d ƒ ˆ  j ƒ  ˆ j ƒ  \ ˆ d <ˆ d <ˆ d j ˆ d j d ƒ ƒ d  S(   Ni   i    i   (   Rþ  R#  R¶  RÝ   RØ   (    (   t   evtt   peerR.  R8  (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRã    s    
R´  R[  i    (   R   RD   R
  Rf   Rm  R‘  RŽ   R‡  R!   R"   R   Rb  RÏ   Rj   R<  Rk  RÒ   R=  Rj  Rl  Rë   RÝ   RØ   Rÿ  Rö   R   Rº   Rz  R‘   (   R&   R0  R(  R)  Rã  RÇ   t   clientt   client_addr(    (   Rå  Ræ  R.  R8  sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_server_accept÷
  s4    		





c      	   C   sx   t  j t  j ƒ } t | j t j ƒ  ƒ ƒ �E } |  j t j ƒ � } | j ƒ  Wd  QX|  j	 | j
 j t j ƒ Wd  QXd  S(   N(   R   RD   R
  R   RÏ   R!   Rv   R×   R
  R‘   Rî   R$   t   ENOTCONN(   R&   R0  Rð   Rñ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_getpeercert_enotconn  s
    c      	   C   sx   t  j t  j ƒ } t | j t j ƒ  ƒ ƒ �E } |  j t j ƒ � } | j ƒ  Wd  QX|  j	 | j
 j t j ƒ Wd  QXd  S(   N(   R   RD   R
  R   RÏ   R!   Rv   R×   R  R‘   Rî   R$   Rê  (   R&   R0  Rð   Rñ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_do_handshake_enotconn%  s
    c         C   sõ   t  j t  j ƒ } | j t ƒ t  j t  j ƒ } t  j | _ t | _ | j	 t  j
 O_	 | j d ƒ | j d ƒ t d | ƒ �Q } | j t j ƒ  d d ƒ} |  j t  j ƒ � | j t | j f ƒ Wd  QXWd  QX|  j d t | j d ƒ ƒ d  S(   Nt   AES128t   AES256R0  R	  R�   s   no shared cipheri    (   R   RD   R
  R‡  R©  Rf   Rm  Rj   RÛ  Rj  Ro   Rg  R6  RÏ   R!   Rv   RE   Rë   Rì   R)  Rh   R¾   RI  (   R&   R”  R“  R8  RÈ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_no_shared_ciphers,  s    		"c         C   s¶   t  j t  j ƒ } t t d t  j d t ƒ�ƒ } t | j t j ƒ  ƒ ƒ �I } |  j	 | j
 ƒ  d ƒ | j t | j f ƒ |  j | j
 ƒ  d ƒ Wd QX|  j	 | j
 ƒ  d ƒ Wd QXd S(   s€   
            Basic tests for SSLSocket.version().
            More tests are done in the test_protocol_*() methods.
            Ró   RJ  RT   N(   R   RD   R÷   R6  RŽ   Rk   R   RÏ   R!   RË  R—   RÒ   Rë   Rì   R)  R‘   (   R&   R0  R8  RÈ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_version_basic@  s    		s%   test requires TLSv1.3 enabled OpenSSLc         C   s¼   t  j t  j ƒ } | j t ƒ | j t  j t  j Bt  j BO_ t	 d | ƒ �h } | j
 t j ƒ  ƒ } t | ƒ �> | j t | j f ƒ |  j | j ƒ  d d d d g ƒ Wd  QXWd  QXd  S(   NR0  i    t   TLS_AES_256_GCM_SHA384t   TLS_CHACHA20_POLY1305_SHA256t   TLS_AES_128_GCM_SHA256(   R   RD   R_  R‡  RŽ   Rj  Rn   Rp   Rq   R6  RÏ   R!   R   Rë   Rì   R)  Rh   RM  (   R&   R0  R8  RÈ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_tls1_3O  s    s"   test requires ECDH-enabled OpenSSLc         C   sÀ   t  j t  j ƒ } | j t ƒ | j t  j O_ t  j d k  rP | j d ƒ n  t	 d | ƒ �[ } t
 | j t j ƒ  ƒ ƒ �7 } | j t | j f ƒ |  j d | j ƒ  d ƒ Wd  QXWd  QXd  S(   Ni   i    s   ECCdraft:ECDHR0  t   ECDH(   i   i    i    (   R   RD   R
  R‡  RŽ   Rj  Ro   R-   Rg  R6  R   RÏ   R!   Rë   Rì   R)  Rh   RM  (   R&   R0  R8  RÈ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_default_ecdh_curveb  s    s
   tls-uniques*   'tls-unique' channel binding not availablec         C   sI  t  j r t j j d ƒ n  t t d t j d t j	 d t d t
 d t ƒ} | �ñt j t j ƒ  d t d t d	 t d
 t j d t j	 ƒ} | j t | j f ƒ | j d ƒ } t  j rÖ t j j d j | ƒ ƒ n  |  j | ƒ |  j t | ƒ d ƒ | j d ƒ | j ƒ  j ƒ  } |  j | t | ƒ j d ƒ ƒ | j ƒ  t j t j ƒ  d t d t d	 t d
 t j d t j	 ƒ} | j t | j f ƒ | j d ƒ } t  j rÄt j j d j | ƒ ƒ n  |  j | | ƒ |  j | ƒ |  j t | ƒ d ƒ | j d ƒ | j ƒ  j ƒ  } |  j | t | ƒ j d ƒ ƒ | j ƒ  Wd QXd S(   s    Test tls-unique channel binding.s   
Rf  Ró   Rg  RJ  RW  Rç   Rè   R  RH  s
   tls-uniques!    got channel binding data: {0!r}
i   s   CB tls-unique
s   us-asciis)    got another channel binding data: {0!r}
N(   R   R   R   R   R   R6  RŽ   R   Rd   R÷   Rj   Rk   RÏ   R!   Rë   Rì   R)  R  RÄ   t   assertIsNotNoneR‘   R  R«   RV  RK  R  Rö   t   assertNotEqual(   R&   R8  RÈ   t   cb_datat   peer_data_reprt   new_cb_data(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR  v  s\    								
			c         C   s„   t  j t  j ƒ } | j t ƒ t | | d t d t ƒ} t j rc t	 j
 j d j | d ƒ ƒ n  |  j | d d  d d h ƒ d  S(   NRJ  RW  s    got compression: {!r}
R‹  t   ZLIBt   RLE(   R   RD   R÷   R‡  RŽ   R™  Rj   R   R   R   R   R   RÄ   Rh   RÒ   (   R&   R0  R×  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_compression²  s    	 R   s*   ssl.OP_NO_COMPRESSION needed for this testc         C   sd   t  j t  j ƒ } | j t ƒ | j t  j O_ t | | d t d t ƒ} |  j	 | d d  ƒ d  S(   NRJ  RW  R‹  (   R   RD   R÷   R‡  RŽ   Rj  R   R™  Rj   RË  RÒ   (   R&   R0  R×  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_compression_disabled»  s    c         C   s±   t  j t  j ƒ } | j t ƒ | j t ƒ | j d ƒ t | | d t	 d t	 ƒ} | d d } | j
 d ƒ } d | k r­ d | k r­ d	 | k r­ |  j d
 | d ƒ n  d  S(   Nt   kEDHRJ  RW  RM  i    t   -t   ADHt   EDHt   DHEs   Non-DH cipher: (   R   RD   R÷   R‡  RŽ   R¨  R©  Rg  R™  Rj   RÄ  R°   (   R&   R0  R×  RM  t   parts(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_dh_paramsÅ  s    $c         C   sR   t  j t  j ƒ } | j t ƒ t | | d t d t ƒ} |  j | d d  ƒ d  S(   NRJ  RW  R�  (	   R   RD   R÷   R‡  RŽ   R™  Rj   RË  RÒ   (   R&   R0  R×  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_selected_alpn_protocolÒ  s
    s   ALPN support requiredc         C   s„   t  j t  j ƒ } | j t ƒ t  j t  j ƒ } | j t ƒ | j d d g ƒ t | | d t d t ƒ} |  j	 | d d  ƒ d  S(   NRt   t   barRJ  RW  R�  (   R   RD   R÷   R‘  RŽ   R‡  Ra  R™  Rj   RË  RÒ   (   R&   R“  R”  R×  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt/   test_selected_alpn_protocol_if_server_uses_alpnÚ  s    s!   ALPN support needed for this testc         C   sÃ  d d d g } d d g d f d d g d f d g d f d d g d  f g } xn| D]f\ } } t j t j ƒ } | j t ƒ | j | ƒ t j t j ƒ } | j t ƒ | j | ƒ y t | | d t d t ƒ} Wn t j	 k
 rö } | } n X| d  k r.t
 r.t j d k  r.|  j | t j	 ƒ qU d t | ƒ t | ƒ t | ƒ f }	 | d }
 |  j |
 | |	 |
 d f ƒ t | d ƒ r˜| d d n d } |  j | | |	 | d f ƒ qU Wd  S(   NRt   R  t	   milkshakes   http/3.0s   http/4.0RJ  RW  i   i    i   sK   failed trying %s (s) and %s (c).
was expecting %s, but got %%s from the %%sR�  Rç  R�  iÿÿÿÿt   nothingR8  (   i   i   i    i   (   RÒ   R   RD   R¾  R‡  RŽ   Ra  R™  Rj   RE   t   IS_OPENSSL_1_1R-   Rº   R¾   R‘   R  (   R&   t   server_protocolst   protocol_testst   client_protocolsR>  R”  R“  R×  R'   RY  t   client_resultt   server_result(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_alpn_protocolsæ  s>    

$c         C   sR   t  j t  j ƒ } | j t ƒ t | | d t d t ƒ} |  j | d d  ƒ d  S(   NRJ  RW  RŽ  (	   R   RD   R÷   R‡  RŽ   R™  Rj   RË  RÒ   (   R&   R0  R×  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_selected_npn_protocol  s
    s    NPN support needed for this testc         C   si  d d g } d d g d f d d g d f d d g d f d d g d f g } x| D]\ } } t  j t  j ƒ } | j t ƒ | j | ƒ t  j t  j ƒ } | j t ƒ | j | ƒ t | | d t d t ƒ} d t | ƒ t | ƒ t | ƒ f } | d	 }	 |  j	 |	 | | |	 d
 f ƒ t
 | d ƒ r>| d d n d }
 |  j	 |
 | | |
 d f ƒ qU Wd  S(   Ns   http/1.1s   spdy/2t   testt   abct   defRJ  RW  sK   failed trying %s (s) and %s (c).
was expecting %s, but got %%s from the %%sRŽ  Rç  R�  iÿÿÿÿR  R8  (   R   RD   R÷   R‡  RŽ   R`  R™  Rj   R¾   R‘   R  (   R&   R  R  R  R>  R”  R“  R×  RY  R  R  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_npn_protocols  s*    
$c         C   sv   t  j t  j ƒ } | j t ƒ t  j t  j ƒ } | j t ƒ t  j t  j ƒ } t  j | _ | j t	 ƒ | | | f S(   N(
   R   RD   R÷   R‡  R©  t   SIGNED_CERTFILE2Rf   Rm  R‘  RÜ  (   R&   R”  t   other_contextR“  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   sni_contexts5  s    c         C   s+   | d } |  j  d | f f | d ƒ d  S(   NRŒ  R€   R†   (   Rh   (   R&   R×  R
   Rý   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   check_common_name?  s    
c            s  g  ‰  |  j  ƒ  \ } ‰ } ‡  ‡ f d †  } | j | ƒ t | | d t d d ƒ} |  j ˆ  d | f g ƒ |  j | d ƒ g  ‰  t | | d t d d  ƒ} |  j ˆ  d  | f g ƒ |  j | d ƒ g  ‰  | j d  ƒ t | | d t d d ƒ} |  j | d ƒ |  j ˆ  g  ƒ d  S(   Nc            s/   ˆ  j  | | f ƒ | d  k	 r+ ˆ |  _ n  d  S(   N(   RB  RÒ   R0  (   R²  t   server_namet   initial_context(   t   callsR  (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   servername_cbH  s    RJ  R–  t   supermessaget   fakehostnameR�   t   notfunny(   R  RÆ  R™  Rj   R‘   R  RÒ   (   R&   R”  R“  R  R×  (    (   R  R  sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyRÇ  C  s,    			c         C   s{   |  j  ƒ  \ } } } d „  } | j | ƒ |  j t j ƒ �" } t | | d t d d ƒ} Wd  QX|  j | j j	 d ƒ d  S(   Nc         S   s   t  j S(   N(   R   t   ALERT_DESCRIPTION_ACCESS_DENIED(   R²  R  R  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   cb_returning_alerto  s    RJ  R–  R   t   TLSV1_ALERT_ACCESS_DENIED(
   R  RÆ  Rv   R   RE   R™  Rk   R‘   Rî   Rú  (   R&   R”  R  R“  R$  Rñ   R×  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_sni_callback_alertj  s    	c         C   s¦   |  j  ƒ  \ } } } d „  } | j | ƒ |  j t j ƒ �7 } t j ƒ  �" } t | | d t d d ƒ} Wd  QXWd  QX|  j	 | j
 j d ƒ |  j d | j ƒ  ƒ d  S(   Nc         S   s   d d d  S(   Ng      ð?g        (    (   R²  R  R  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt
   cb_raising~  s    RJ  R–  R   t   SSLV3_ALERT_HANDSHAKE_FAILUREt   ZeroDivisionError(   R  RÆ  Rv   R   RE   R   t   captured_stderrR™  Rk   R‘   Rî   Rú  Rh   t   getvalue(   R&   R”  R  R“  R'  Rñ   t   stderrR×  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   test_sni_callback_raisingy  s    	c         C   s¦   |  j  ƒ  \ } } } d „  } | j | ƒ |  j t j ƒ �7 } t j ƒ  �" } t | | d t d d ƒ} Wd  QXWd  QX|  j	 | j
 j d ƒ |  j d | j ƒ  ƒ d  S(   Nc         S   s   d S(   NRt   (    (   R²  R  R  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   cb_wrong_return_type�  s    RJ  R–  R   t   TLSV1_ALERT_INTERNAL_ERRORRw   (   R  RÆ  Rv   R   RE   R   R*  R™  Rk   R‘   Rî   Rú  Rh   R+  (   R&   R”  R  R“  R.  Rñ   R,  R×  (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt#   test_sni_callback_wrong_return_typeŠ  s    	c         C   s¿   t  j t  j ƒ } t  j | _ | j t ƒ | j t ƒ t d | d t	 ƒ } | �f | j
 t j ƒ  ƒ } | j t | j f ƒ | j ƒ  |  j t | j d ƒ |  j t | j d ƒ Wd  QXd  S(   NR0  RJ  i   t   hello(   R   RD   R
  Rf   Rm  R‘  RŽ   R‡  R6  Rk   RÏ   R!   Rë   Rì   R)  Rö   Rv   Rê   R«   R   (   R&   R0  R8  RÈ   (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt,   test_read_write_after_close_raises_valuerrorœ  s    
(8   R)   R*   RQ   R¥  R¨  RH   R\  R/   R«  Rñ  R­  Rµ  RN   R   R·  Rb   R¸  Rº  R»  R½  R¿  RÂ  RË  RÌ  RÛ  RÞ  Rä  Ré  Rë  Rì  Rï  Rð  t   HAS_TLSv1_3Rô  Rg   Rö  R]  R  Rþ  Rÿ  R  R  t   HAS_ALPNR	  R  R  t   HAS_NPNR  R  R  Rò  RÇ  R&  R-  R0  R2  (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyR¤  k  sn   	&*	&	!	)(	:			w		1	'				;					*		
	'c         C   sÑ  t  j ræ i t j d 6t j d 6t j d 6} xY | j ƒ  D]9 \ } } | ƒ  } | r: | d r: d | | f } Pq: q: Wt t j ƒ  ƒ } d t j	 t j
 f GHd | GHd t j GHd	 t j GHy d
 t j GHWqæ t k
 râ qæ Xn  x] t t t t t t t t t t t t t g D]. } t j j | ƒ st  j d | ƒ ‚ qqWt  t! t" t# g } t  j$ d ƒ rw| j% t& ƒ n  t' r¢t  j( ƒ  } | r¢| j% t) ƒ q¢n  z t  j* | Œ  Wd  t' rÌt  j+ | Œ  n  Xd  S(   Nt   Linuxt   Mact   Windowsi    s   %s %rs   test_ssl: testing with %r %rs             under %ss             HAS_SNI = %rs             OP_ALL = 0x%8xs             OP_NO_TLSv1_1 = 0x%8xs   Can't read certificate file %rt   network(,   R   R   RF   RG   t   mac_vert	   win32_vert   itemsRK  R   R¹   R-   Ri   Ri  Rp   t   AttributeErrorRŽ   R  R’  RŠ  R‹  RŒ  R�  R©  R  RÜ  Rˆ  t   BADKEYR‰  R   R   t   existst
   TestFailedR_  R   Rc   Rô  t   is_resource_enabledRB  R  t   _have_threadst   threading_setupR¤  t   run_unittestt   threading_cleanup(   R   t   platsR
   RL   t   platR®  t   testst   thread_info(    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt	   test_main¬  sL    	

				t   __main__(k   R   RH   R  R    R   t   test.script_helperR   Ru  R!   R  R0   R9   RÉ  R   R$   R�   R¬  RÅ  R   RÐ   RF   RX   RO   t
   contextlibR   t   import_moduleR   t   sortedt   _PROTOCOL_NAMESR`  Rì   R¹   R®   RÂ   R-   R  R   RŽ   R  R¦  R’  RŠ  R‹  RŒ  R�  RŽ  R�  R{  R  R“  Rœ  Rª   Rª  R©  R  RÜ  R¨   R	  R  R‰  Rˆ  Rí   R>  R’   R¢   R˜   R©  Rª  Rp  R   R   R   R   R   R   t   TestCaseR   R,   R.   R/   R6   R@   RQ   Rb   R\  Ri   Rò  Rc   R_  Rô  R  R<  t   ImportErrorRk   RB  Rj   t   test.ssl_serversR5  R=  R6  Rs  RÒ   R™  R£  R¤  RJ  R)   (    (    (    sƒ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_ssl.pyt   <module>   sÄ   										ÿ ÿ iÿ ÿ $)ÿ /
ßu.;ÿ ÿ ÿ ÿ E0