Skip to content

Test mbedtls_ssl_conf_own_cert #10217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 32 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
353eb33
Use TEST_EQUAL(a,b) instead of TEST_ASSERT(a==b)
gilles-peskine-arm May 14, 2025
b6bb3fb
Flatten out mbedtls_test_ssl_endpoint_certificate structure
gilles-peskine-arm May 26, 2025
35a2d9b
Remove testing of mbedtls_ssl_conf_own_cert(NULL)
gilles-peskine-arm May 26, 2025
0677e02
Move timer into the endpoint structure
gilles-peskine-arm May 27, 2025
2744a43
Refactor set_ciphersuites to work on the endpoint structure
gilles-peskine-arm May 27, 2025
c4949d1
mbedtls_ssl_conf_alpn_protocols: declare list elements as const
gilles-peskine-arm May 27, 2025
9b99368
mbedtls_test_ssl_perform_handshake: declare options as const
gilles-peskine-arm May 27, 2025
2996959
Move DTLS context into the endpoint structure
gilles-peskine-arm May 27, 2025
b092e78
New auxiliary function mbedtls_test_ssl_dtls_join_endpoints
gilles-peskine-arm May 27, 2025
6c154e7
Move queue management into mbedtls_test_ssl_dtls_join_endpoints
gilles-peskine-arm May 27, 2025
ca8a9ac
Remove unused parameters to endpoint init/free
gilles-peskine-arm May 27, 2025
07432b9
Unify identical code
gilles-peskine-arm May 27, 2025
e30b5c7
mbedtls_test_ssl_perform_handshake: make client, server pointers
gilles-peskine-arm May 27, 2025
78df6ae
Move renegotiation testing into its own function
gilles-peskine-arm May 27, 2025
e23a6d1
Move serialization testing into its own function
gilles-peskine-arm May 27, 2025
bd95340
Unify SSL version checks between client and server
gilles-peskine-arm May 28, 2025
7a8fd46
Separate test function to perform an SSL connection
gilles-peskine-arm May 28, 2025
27586d8
Move more endpoint configuration into the setup function
gilles-peskine-arm May 28, 2025
fb2ce05
SSL tests: make client authentication more uniform, defaulting on
gilles-peskine-arm May 28, 2025
6e4d245
Move certificate and key parsing to auxiliary functions
gilles-peskine-arm May 27, 2025
a6e71f9
Don't change the configuration after mbedtls_ssl_setup
gilles-peskine-arm Jun 1, 2025
00eb072
mbedtls_test_ssl_endpoint_init: store user_data_n in the endpoint object
gilles-peskine-arm Jun 1, 2025
6edb76c
mbedtls_test_ssl_endpoint_init: split configuration and setup
gilles-peskine-arm Jun 1, 2025
42e8d42
Expand handshake_ciphersuite_select
gilles-peskine-arm Jun 2, 2025
e9c6c85
Simplify ownership of opaque key in SSL test endpoint
gilles-peskine-arm Jun 2, 2025
f697697
Break out key and certificate loading into separate functions
gilles-peskine-arm Jun 2, 2025
972f726
Allow endpoint init to skip loading a key and certificate
gilles-peskine-arm Jun 2, 2025
3c3001e
Automate debug logs in SSL tests more
gilles-peskine-arm Jun 11, 2025
fabb20e
Show debug logs in SSL tests based on a variable
gilles-peskine-arm Jun 11, 2025
df8d383
SSL test debug logs: show endpoint name
gilles-peskine-arm Jun 11, 2025
fb7cb97
Server-side tests for mbedtls_ssl_conf_own_cert
gilles-peskine-arm Jun 12, 2025
9fff313
Comment out known broken test cases
gilles-peskine-arm Jun 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog.d/mbedtls_ssl_conf_alpn_protocols.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
API changes
* The list passed to mbedtls_ssl_conf_alpn_protocols() is now declared
as having const elements, reflecting the fact that the library will
not modify it
5 changes: 3 additions & 2 deletions include/mbedtls/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,7 @@ struct mbedtls_ssl_config {
#endif /* MBEDTLS_SSL_EARLY_DATA */

#if defined(MBEDTLS_SSL_ALPN)
const char **MBEDTLS_PRIVATE(alpn_list); /*!< ordered list of protocols */
const char *const *MBEDTLS_PRIVATE(alpn_list); /*!< ordered list of protocols */
#endif

#if defined(MBEDTLS_SSL_DTLS_SRTP)
Expand Down Expand Up @@ -4011,7 +4011,8 @@ int mbedtls_ssl_set_hs_ecjpake_password_opaque(mbedtls_ssl_context *ssl,
*
* \return 0 on success, or MBEDTLS_ERR_SSL_BAD_INPUT_DATA.
*/
int mbedtls_ssl_conf_alpn_protocols(mbedtls_ssl_config *conf, const char **protos);
int mbedtls_ssl_conf_alpn_protocols(mbedtls_ssl_config *conf,
const char *const *protos);

/**
* \brief Get the name of the negotiated Application Layer Protocol.
Expand Down
2 changes: 1 addition & 1 deletion library/ssl_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static int ssl_write_alpn_ext(mbedtls_ssl_context *ssl,
* ProtocolName protocol_name_list<2..2^16-1>
* } ProtocolNameList;
*/
for (const char **cur = ssl->conf->alpn_list; *cur != NULL; cur++) {
for (const char *const *cur = ssl->conf->alpn_list; *cur != NULL; cur++) {
/*
* mbedtls_ssl_conf_set_alpn_protocols() checked that the length of
* protocol names is less than 255.
Expand Down
9 changes: 5 additions & 4 deletions library/ssl_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -2534,10 +2534,11 @@ void mbedtls_ssl_conf_sni(mbedtls_ssl_config *conf,
#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */

#if defined(MBEDTLS_SSL_ALPN)
int mbedtls_ssl_conf_alpn_protocols(mbedtls_ssl_config *conf, const char **protos)
int mbedtls_ssl_conf_alpn_protocols(mbedtls_ssl_config *conf,
const char *const *protos)
{
size_t cur_len, tot_len;
const char **p;
const char *const *p;

/*
* RFC 7301 3.1: "Empty strings MUST NOT be included and byte strings
Expand Down Expand Up @@ -5111,7 +5112,7 @@ static int ssl_context_load(mbedtls_ssl_context *ssl,
#if defined(MBEDTLS_SSL_ALPN)
{
uint8_t alpn_len;
const char **cur;
const char *const *cur;

if ((size_t) (end - p) < 1) {
return MBEDTLS_ERR_SSL_BAD_INPUT_DATA;
Expand Down Expand Up @@ -8547,7 +8548,7 @@ int mbedtls_ssl_parse_alpn_ext(mbedtls_ssl_context *ssl,
}

/* Use our order of preference */
for (const char **alpn = ssl->conf->alpn_list; *alpn != NULL; alpn++) {
for (const char *const *alpn = ssl->conf->alpn_list; *alpn != NULL; alpn++) {
size_t const alpn_len = strlen(*alpn);
p = protocol_name_list;
while (p < protocol_name_list_end) {
Expand Down
2 changes: 1 addition & 1 deletion library/ssl_tls12_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ static int ssl_parse_alpn_ext(mbedtls_ssl_context *ssl,
const unsigned char *buf, size_t len)
{
size_t list_len, name_len;
const char **p;
const char *const *p;

/* If we didn't send it, the server shouldn't send it */
if (ssl->conf->alpn_list == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion library/ssl_tls13_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static int ssl_tls13_parse_alpn_ext(mbedtls_ssl_context *ssl,

/* Check that the server chosen protocol was in our list and save it */
MBEDTLS_SSL_CHK_BUF_READ_PTR(p, protocol_name_list_end, protocol_name_len);
for (const char **alpn = ssl->conf->alpn_list; *alpn != NULL; alpn++) {
for (const char *const *alpn = ssl->conf->alpn_list; *alpn != NULL; alpn++) {
if (protocol_name_len == strlen(*alpn) &&
memcmp(p, *alpn, protocol_name_len) == 0) {
ssl->alpn_chosen = *alpn;
Expand Down
Loading