tests: Work around pyopenssl API change
OpenSSL.SSL.Connection.state_string() was replaced with get_state_string() in pyopenssl. Add workaround code to be able to use either of these names. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
parent
5118319831
commit
33a6da6908
1 changed files with 14 additions and 18 deletions
|
@ -8029,6 +8029,14 @@ def run_eap_fast_phase2(dev, test_payload, test_failure=True):
|
|||
def ssl_info_callback(conn, where, ret):
|
||||
logger.debug("SSL: info where=%d ret=%d" % (where, ret))
|
||||
|
||||
def log_conn_state(conn):
|
||||
try:
|
||||
state = conn.state_string()
|
||||
except AttributeError:
|
||||
state = conn.get_state_string()
|
||||
if state:
|
||||
logger.info("State: " + state)
|
||||
|
||||
def process_clienthello(ctx, payload):
|
||||
logger.info("Process ClientHello")
|
||||
ctx['sslctx'] = OpenSSL.SSL.Context(OpenSSL.SSL.TLSv1_METHOD)
|
||||
|
@ -8037,43 +8045,31 @@ def run_eap_fast_phase2(dev, test_payload, test_failure=True):
|
|||
ctx['sslctx'].set_cipher_list("ADH-AES128-SHA")
|
||||
ctx['conn'] = OpenSSL.SSL.Connection(ctx['sslctx'], None)
|
||||
ctx['conn'].set_accept_state()
|
||||
state = ctx['conn'].state_string()
|
||||
if state:
|
||||
logger.info("State: " + state)
|
||||
log_conn_state(ctx['conn'])
|
||||
ctx['conn'].bio_write(payload)
|
||||
try:
|
||||
ctx['conn'].do_handshake()
|
||||
except OpenSSL.SSL.WantReadError:
|
||||
pass
|
||||
state = ctx['conn'].state_string()
|
||||
if state:
|
||||
logger.info("State: " + state)
|
||||
log_conn_state(ctx['conn'])
|
||||
data = ctx['conn'].bio_read(4096)
|
||||
state = ctx['conn'].state_string()
|
||||
if state:
|
||||
logger.info("State: " + state)
|
||||
log_conn_state(ctx['conn'])
|
||||
return struct.pack(">BBHBB", EAP_CODE_REQUEST, ctx['id'],
|
||||
4 + 1 + 1 + len(data),
|
||||
EAP_TYPE_FAST, 0x01) + data
|
||||
|
||||
def process_clientkeyexchange(ctx, payload, appl_data):
|
||||
logger.info("Process ClientKeyExchange")
|
||||
state = ctx['conn'].state_string()
|
||||
if state:
|
||||
logger.info("State: " + state)
|
||||
log_conn_state(ctx['conn'])
|
||||
ctx['conn'].bio_write(payload)
|
||||
try:
|
||||
ctx['conn'].do_handshake()
|
||||
except OpenSSL.SSL.WantReadError:
|
||||
pass
|
||||
ctx['conn'].send(appl_data)
|
||||
state = ctx['conn'].state_string()
|
||||
if state:
|
||||
logger.info("State: " + state)
|
||||
log_conn_state(ctx['conn'])
|
||||
data = ctx['conn'].bio_read(4096)
|
||||
state = ctx['conn'].state_string()
|
||||
if state:
|
||||
logger.info("State: " + state)
|
||||
log_conn_state(ctx['conn'])
|
||||
return struct.pack(">BBHBB", EAP_CODE_REQUEST, ctx['id'],
|
||||
4 + 1 + 1 + len(data),
|
||||
EAP_TYPE_FAST, 0x01) + data
|
||||
|
|
Loading…
Reference in a new issue