aboutsummaryrefslogtreecommitdiff
path: root/src/supplemental/tls/tls_test.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-11-09 15:24:43 -0800
committerGarrett D'Amore <garrett@damore.org>2024-11-09 16:27:45 -0800
commit0058b766b91f08b34dcef3c7bb55b216099f3f66 (patch)
tree5ac1fa105d707018cdfa9f5244da5837a8c31601 /src/supplemental/tls/tls_test.c
parent150d80c2c62ce3693dbbd0256c16337879c7d825 (diff)
downloadnng-0058b766b91f08b34dcef3c7bb55b216099f3f66.tar.gz
nng-0058b766b91f08b34dcef3c7bb55b216099f3f66.tar.bz2
nng-0058b766b91f08b34dcef3c7bb55b216099f3f66.zip
TLS configuration changed to use discret _set_tls and _get_tls functions.
This is simpler, and more reliable than using socket options.
Diffstat (limited to 'src/supplemental/tls/tls_test.c')
-rw-r--r--src/supplemental/tls/tls_test.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/supplemental/tls/tls_test.c b/src/supplemental/tls/tls_test.c
index 3d0c16a0..9317890d 100644
--- a/src/supplemental/tls/tls_test.c
+++ b/src/supplemental/tls/tls_test.c
@@ -106,7 +106,7 @@ test_tls_large_message(void)
NUTS_PASS(nng_tls_config_alloc(&c1, NNG_TLS_MODE_SERVER));
NUTS_PASS(nng_tls_config_own_cert(
c1, nuts_server_crt, nuts_server_key, NULL));
- NUTS_PASS(nng_stream_listener_set_ptr(l, NNG_OPT_TLS_CONFIG, c1));
+ NUTS_PASS(nng_stream_listener_set_tls(l, c1));
NUTS_PASS(nng_stream_listener_listen(l));
NUTS_PASS(
nng_stream_listener_get_int(l, NNG_OPT_TCP_BOUND_PORT, &port));
@@ -119,7 +119,7 @@ test_tls_large_message(void)
NUTS_PASS(nng_tls_config_ca_chain(c2, nuts_server_crt, NULL));
NUTS_PASS(nng_tls_config_server_name(c2, "localhost"));
- NUTS_PASS(nng_stream_dialer_set_ptr(d, NNG_OPT_TLS_CONFIG, c2));
+ NUTS_PASS(nng_stream_dialer_set_tls(d, c2));
nng_stream_listener_accept(l, aio1);
nng_stream_dialer_dial(d, aio2);
@@ -211,7 +211,7 @@ test_tls_psk(void)
NUTS_PASS(nng_stream_listener_alloc(&l, "tls+tcp://127.0.0.1:0"));
NUTS_PASS(nng_tls_config_alloc(&c1, NNG_TLS_MODE_SERVER));
NUTS_PASS(nng_tls_config_psk(c1, "identity", key, sizeof(key)));
- NUTS_PASS(nng_stream_listener_set_ptr(l, NNG_OPT_TLS_CONFIG, c1));
+ NUTS_PASS(nng_stream_listener_set_tls(l, c1));
NUTS_PASS(nng_stream_listener_listen(l));
NUTS_PASS(
nng_stream_listener_get_int(l, NNG_OPT_TCP_BOUND_PORT, &port));
@@ -223,7 +223,7 @@ test_tls_psk(void)
NUTS_PASS(nng_tls_config_alloc(&c2, NNG_TLS_MODE_CLIENT));
NUTS_PASS(nng_tls_config_psk(c2, "identity", key, sizeof(key)));
- NUTS_PASS(nng_stream_dialer_set_ptr(d, NNG_OPT_TLS_CONFIG, c2));
+ NUTS_PASS(nng_stream_dialer_set_tls(d, c2));
nng_stream_listener_accept(l, aio1);
nng_stream_dialer_dial(d, aio2);
@@ -301,7 +301,7 @@ test_tls_psk_server_identities(void)
nng_tls_config_psk(c1, "identity2", key + 4, sizeof(key) - 4));
NUTS_PASS(nng_tls_config_psk(c1, identity, key + 4, sizeof(key) - 4));
NUTS_PASS(nng_tls_config_psk(c1, identity, key, sizeof(key)));
- NUTS_PASS(nng_stream_listener_set_ptr(l, NNG_OPT_TLS_CONFIG, c1));
+ NUTS_PASS(nng_stream_listener_set_tls(l, c1));
NUTS_PASS(nng_stream_listener_listen(l));
NUTS_PASS(
nng_stream_listener_get_int(l, NNG_OPT_TCP_BOUND_PORT, &port));
@@ -313,7 +313,7 @@ test_tls_psk_server_identities(void)
NUTS_PASS(nng_tls_config_alloc(&c2, NNG_TLS_MODE_CLIENT));
NUTS_PASS(nng_tls_config_psk(c2, identity, key, sizeof(key)));
- NUTS_PASS(nng_stream_dialer_set_ptr(d, NNG_OPT_TLS_CONFIG, c2));
+ NUTS_PASS(nng_stream_dialer_set_tls(d, c2));
nng_stream_listener_accept(l, aio1);
nng_stream_dialer_dial(d, aio2);
@@ -387,7 +387,7 @@ test_tls_psk_bad_identity(void)
NUTS_PASS(nng_tls_config_alloc(&c1, NNG_TLS_MODE_SERVER));
// Replace the identity .. first write one value, then we change it
NUTS_PASS(nng_tls_config_psk(c1, "identity1", key, sizeof(key)));
- NUTS_PASS(nng_stream_listener_set_ptr(l, NNG_OPT_TLS_CONFIG, c1));
+ NUTS_PASS(nng_stream_listener_set_tls(l, c1));
NUTS_PASS(nng_stream_listener_listen(l));
NUTS_PASS(
nng_stream_listener_get_int(l, NNG_OPT_TCP_BOUND_PORT, &port));
@@ -400,7 +400,7 @@ test_tls_psk_bad_identity(void)
NUTS_PASS(nng_tls_config_psk(c2, "identity2", key, sizeof(key)));
NUTS_PASS(nng_tls_config_server_name(c2, "localhost"));
- NUTS_PASS(nng_stream_dialer_set_ptr(d, NNG_OPT_TLS_CONFIG, c2));
+ NUTS_PASS(nng_stream_dialer_set_tls(d, c2));
nng_stream_listener_accept(l, aio1);
nng_stream_dialer_dial(d, aio2);
@@ -463,7 +463,7 @@ test_tls_psk_config_busy(void)
NUTS_PASS(nng_stream_listener_alloc(&l, "tls+tcp://127.0.0.1:0"));
NUTS_PASS(nng_tls_config_alloc(&c1, NNG_TLS_MODE_SERVER));
NUTS_PASS(nng_tls_config_psk(c1, "identity", key, sizeof(key)));
- NUTS_PASS(nng_stream_listener_set_ptr(l, NNG_OPT_TLS_CONFIG, c1));
+ NUTS_PASS(nng_stream_listener_set_tls(l, c1));
nng_stream_listener_accept(l, aio);
nng_msleep(100);
NUTS_FAIL(