mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-13 05:47:11 +00:00
feat(mbedtls): add support for dynamic buffer for TLS1.3
Closes https://github.com/espressif/esp-idf/issues/15448
This commit is contained in:
@@ -125,6 +125,90 @@ def test_examples_protocol_https_request_cli_session_tickets(dut: Dut) -> None:
|
||||
thread1.terminate()
|
||||
|
||||
|
||||
@pytest.mark.ethernet
|
||||
@pytest.mark.parametrize(
|
||||
'config',
|
||||
[
|
||||
'ssldyn_tls1_3',
|
||||
],
|
||||
indirect=True,
|
||||
)
|
||||
@pytest.mark.parametrize('erase_nvs', ['y'], indirect=True)
|
||||
@idf_parametrize('target', ['esp32'], indirect=['target'])
|
||||
def test_examples_protocol_https_request_dynamic_buffers_tls1_3(dut: Dut) -> None:
|
||||
# Check for tls 1.3 connection using crt bundle with mbedtls dynamic resource enabled
|
||||
# check and log bin size
|
||||
binary_file = os.path.join(dut.app.binary_path, 'https_request.bin')
|
||||
bin_size = os.path.getsize(binary_file)
|
||||
logging.info('https_request_bin_size : {}KB'.format(bin_size // 1024))
|
||||
# start https server
|
||||
server_port = 8070
|
||||
server_file = os.path.join(os.path.dirname(__file__), 'main', 'local_server_cert.pem')
|
||||
key_file = os.path.join(os.path.dirname(__file__), 'main', 'local_server_key.pem')
|
||||
thread1 = multiprocessing.Process(target=start_https_server, args=(server_file, key_file, '0.0.0.0', server_port))
|
||||
thread1.daemon = True
|
||||
thread1.start()
|
||||
logging.info('The server started on localhost:{}'.format(server_port))
|
||||
|
||||
dut.expect('Loaded app from partition at offset', timeout=30)
|
||||
try:
|
||||
try:
|
||||
ip_address = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)[^\d]', timeout=60)[1].decode()
|
||||
print('Connected to AP/Ethernet with IP: {}'.format(ip_address))
|
||||
host_ip = get_host_ip4_by_dest_ip(ip_address)
|
||||
dut.expect('Start https_request example', timeout=30)
|
||||
print('writing to device: {}'.format('https://' + host_ip + ':' + str(server_port)))
|
||||
dut.write('https://' + host_ip + ':' + str(server_port))
|
||||
except pexpect.exceptions.TIMEOUT:
|
||||
raise ValueError('ENV_TEST_FAILURE: Cannot connect to AP/Ethernet')
|
||||
# Check for connection using already saved client session
|
||||
try:
|
||||
dut.expect('https_request to local server', timeout=30)
|
||||
dut.expect(
|
||||
['Connection established...', 'Reading HTTP response...', 'HTTP/1.1 200 OK', 'connection closed'],
|
||||
expect_all=True,
|
||||
)
|
||||
except Exception:
|
||||
logging.info('Failed to connect to local https server"')
|
||||
raise
|
||||
|
||||
try:
|
||||
dut.expect('https_request using saved client session', timeout=20)
|
||||
dut.expect(
|
||||
['Connection established...', 'Reading HTTP response...', 'HTTP/1.1 200 OK', 'connection closed'],
|
||||
expect_all=True,
|
||||
)
|
||||
except Exception:
|
||||
logging.info('Failed the test for "https_request using saved client session"')
|
||||
raise
|
||||
# only check if one connection is established
|
||||
logging.info('Testing for "https_request using crt bundle" with mbedtls dynamic resource enabled')
|
||||
try:
|
||||
dut.expect('https_request using crt bundle', timeout=30)
|
||||
dut.expect(
|
||||
[
|
||||
'Connection established...',
|
||||
'Reading HTTP response...',
|
||||
'HTTP/1.1 200 OK',
|
||||
'TLS 1.3',
|
||||
'connection closed',
|
||||
],
|
||||
expect_all=True,
|
||||
)
|
||||
except Exception:
|
||||
logging.info(
|
||||
'Failed the test for "https_request using crt bundle" with TLS 1.3 '
|
||||
'when mbedtls dynamic resource was enabled'
|
||||
)
|
||||
raise
|
||||
logging.info(
|
||||
'Passed the test for "https_request using crt bundle" with TLS 1.3 when '
|
||||
'mbedtls dynamic resource was enabled'
|
||||
)
|
||||
finally:
|
||||
thread1.terminate()
|
||||
|
||||
|
||||
@pytest.mark.ethernet
|
||||
@pytest.mark.parametrize(
|
||||
'config',
|
||||
|
Reference in New Issue
Block a user