Skip to content

Commit 8f07784

Browse files
mrodgers-witekionashif
authored andcommitted
tests: http_server: fix failing TLS tests due to moved certificates
Testcase uses certificates from the sample application at samples/net/sockets/http_server. These were modified and moved into a different folder by a previous commit, causing a build failure in the test. Testcase updated to: - use new path to certificates - update available cipher suites, since certificates now use ECDSA - update expected hostname in certificate The CA certificate in the sample app is also converted to .der format for inclusion in the test (the content is exactly the same as the PEM version, just converted to DER). Signed-off-by: Matt Rodgers <[email protected]>
1 parent 90ff9c0 commit 8f07784

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed
488 Bytes
Binary file not shown.

tests/net/lib/http_server/tls/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,33 @@ set(gen_dir ${ZEPHYR_BINARY_DIR}/include/generated/)
1212
if (${CONFIG_TLS_CREDENTIALS})
1313
generate_inc_file_for_target(
1414
app
15-
${ZEPHYR_BASE}/samples/net/sockets/http_server/src/ca.der
15+
${ZEPHYR_BASE}/samples/net/sockets/http_server/src/certs/ca_cert.der
1616
${gen_dir}/ca.inc
1717
)
1818

1919
generate_inc_file_for_target(
2020
app
21-
${ZEPHYR_BASE}/samples/net/sockets/http_server/src/server.der
21+
${ZEPHYR_BASE}/samples/net/sockets/http_server/src/certs/server_cert.der
2222
${gen_dir}/server.inc
2323
)
2424

2525
generate_inc_file_for_target(
2626
app
27-
${ZEPHYR_BASE}/samples/net/sockets/http_server/src/server_privkey.der
27+
${ZEPHYR_BASE}/samples/net/sockets/http_server/src/certs/server_privkey.der
2828
${gen_dir}/server_privkey.inc
2929
)
3030

3131
# we reuse the same certificate / private key for client
3232
# since it seems to be the only one that is signed by a ca
3333
generate_inc_file_for_target(
3434
app
35-
${ZEPHYR_BASE}/samples/net/sockets/http_server/src/server.der
35+
${ZEPHYR_BASE}/samples/net/sockets/http_server/src/certs/server_cert.der
3636
${gen_dir}/client.inc
3737
)
3838

3939
generate_inc_file_for_target(
4040
app
41-
${ZEPHYR_BASE}/samples/net/sockets/http_server/src/server_privkey.der
41+
${ZEPHYR_BASE}/samples/net/sockets/http_server/src/certs/server_privkey.der
4242
${gen_dir}/client_privkey.inc
4343
)
4444
endif()

tests/net/lib/http_server/tls/prj.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ CONFIG_MBEDTLS=y
3131
CONFIG_MBEDTLS_BUILTIN=y
3232
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=2048
3333
CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=6
34+
CONFIG_MBEDTLS_ECDH_C=y
35+
CONFIG_MBEDTLS_ECDSA_C=y
36+
CONFIG_MBEDTLS_ECP_C=y
37+
CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y
38+
CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_ENABLED=n
39+
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y
40+
CONFIG_MBEDTLS_CIPHER_CCM_ENABLED=y
41+
CONFIG_MBEDTLS_CIPHER_GCM_ENABLED=y
3442

3543
# Network buffers / packets / sizes
3644
CONFIG_NET_BUF_TX_COUNT=32

tests/net/lib/http_server/tls/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ static void test_tls(void)
167167
sec_tag_list, sec_tag_list_size);
168168
zassert_not_equal(ret, -1, "failed to set TLS_SEC_TAG_LIST (%d)", errno);
169169

170-
ret = zsock_setsockopt(client_fd, SOL_TLS, TLS_HOSTNAME,
171-
"localhost", sizeof("localhost"));
170+
ret = zsock_setsockopt(client_fd, SOL_TLS, TLS_HOSTNAME, "zephyr.local",
171+
sizeof("zephyr.local"));
172172
zassert_not_equal(ret, -1, "failed to set TLS_HOSTNAME (%d)", errno);
173173
}
174174

0 commit comments

Comments
 (0)