Ignore:
Timestamp:
09/18/17 18:53:24 (7 years ago)
Author:
tim
Message:

minor annoyances

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/bletchley/ssltls.py

    r130 r131  
    7575    if mode == 'client':
    7676        conn.set_connect_state()
    77         # This hokey crap is required because OpenSSL wants you to poll rather than just block
    78         # XXX: tie this sleep time into the timeout parameter
    79         for tries in range(0,10):
    80             try:
    81                 conn.do_handshake()
    82                 break
    83             except OpenSSL.SSL.WantReadError as e:
    84                 time.sleep(0.1)
     77        if timeout:
     78            # This polling is needed because the socket timeouts have put the
     79            # socket in non-blocking mode
     80            start = time.time()+timeout
     81            while time.time() < start:
     82                try:
     83                    conn.do_handshake()
     84                    break
     85                except (OpenSSL.SSL.WantReadError,OpenSSL.SSL.WantWriteError) as e:
     86                    time.sleep(0.00001)
     87        else:
     88            conn.do_handshake()
     89
    8590    else:
    8691        conn.set_accept_state()
Note: See TracChangeset for help on using the changeset viewer.