aboutsummaryrefslogtreecommitdiffstats
path: root/test/sslapitest.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2018-07-05 17:19:03 +0100
committerMatt Caswell <matt@openssl.org>2018-07-17 10:12:10 +0100
commit04d7814a8038e01dbeb9fd7721d40c1824f553a8 (patch)
tree61cb324fae3d1d5401591f5d195ca2028cb18e47 /test/sslapitest.c
parent84475ccb70da709c9a0035561429a34700b565d9 (diff)
downloadopenssl-04d7814a8038e01dbeb9fd7721d40c1824f553a8.tar.gz
Improve testing of stateful tickets
Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/6722)
Diffstat (limited to 'test/sslapitest.c')
-rw-r--r--test/sslapitest.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/test/sslapitest.c b/test/sslapitest.c
index cdac8bc454..a832f7d1ec 100644
--- a/test/sslapitest.c
+++ b/test/sslapitest.c
@@ -1233,11 +1233,11 @@ static int post_handshake_verify(SSL *sssl, SSL *cssl)
return 1;
}
-static int test_tickets(int idx)
+static int test_tickets(int stateful, int idx)
{
SSL_CTX *sctx = NULL, *cctx = NULL;
SSL *serverssl = NULL, *clientssl = NULL;
- int testresult = 0, i;
+ int testresult = 0, sess_id_ctx = 1, i;
size_t j;
/* idx is the test number, but also the number of tickets we want */
@@ -1248,9 +1248,15 @@ static int test_tickets(int idx)
if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),
TLS1_VERSION, TLS_MAX_VERSION, &sctx,
&cctx, cert, privkey))
- || !TEST_true(SSL_CTX_set_num_tickets(sctx, idx)))
+ || !TEST_true(SSL_CTX_set_num_tickets(sctx, idx))
+ || !TEST_true(SSL_CTX_set_session_id_context(sctx,
+ (void *)&sess_id_ctx,
+ sizeof(sess_id_ctx))))
goto end;
+ if (stateful)
+ SSL_CTX_set_options(sctx, SSL_OP_NO_TICKET);
+
SSL_CTX_set_session_cache_mode(cctx, SSL_SESS_CACHE_CLIENT
| SSL_SESS_CACHE_NO_INTERNAL_STORE);
SSL_CTX_sess_set_new_cb(cctx, new_cachesession_cb);
@@ -1327,6 +1333,16 @@ static int test_tickets(int idx)
return testresult;
}
+
+static int test_stateless_tickets(int idx)
+{
+ return test_tickets(0, idx);
+}
+
+static int test_stateful_tickets(int idx)
+{
+ return test_tickets(1, idx);
+}
#endif
#define USE_NULL 0
@@ -5272,7 +5288,8 @@ int setup_tests(void)
ADD_TEST(test_session_with_only_ext_cache);
ADD_TEST(test_session_with_both_cache);
#ifndef OPENSSL_NO_TLS1_3
- ADD_ALL_TESTS(test_tickets, 3);
+ ADD_ALL_TESTS(test_stateful_tickets, 3);
+ ADD_ALL_TESTS(test_stateless_tickets, 3);
#endif
ADD_ALL_TESTS(test_ssl_set_bio, TOTAL_SSL_SET_BIO_TESTS);
ADD_TEST(test_ssl_bio_pop_next_bio);