From c1dbbcc81e2ce9f11979cb1889c4174f44c16afd Mon Sep 17 00:00:00 2001 From: John Bland Date: Tue, 16 Apr 2024 13:21:04 -0400 Subject: [PATCH 1/3] add wolfSSLSessionIsSetup so the user can check if a session ticket has been sent by the server --- tests/api.c | 1 + wolfssl/ssl.h | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/api.c b/tests/api.c index 698afe2a2..bc94b5dc9 100644 --- a/tests/api.c +++ b/tests/api.c @@ -47152,6 +47152,7 @@ static int test_wolfSSL_SESSION(void) ExpectPtrNE((sess = wolfSSL_get1_session(ssl)), NULL); /* ref count 1 */ ExpectPtrNE((sess_copy = wolfSSL_get1_session(ssl)), NULL); /* ref count 2 */ + ExpectIntEQ(wolfSSLSessionIsSetup(sess), 1); #ifdef HAVE_EXT_CACHE ExpectPtrEq(sess, sess_copy); /* they should be the same pointer but without * HAVE_EXT_CACHE we get new objects each time */ diff --git a/wolfssl/ssl.h b/wolfssl/ssl.h index 7f8b27264..5c097fb7f 100644 --- a/wolfssl/ssl.h +++ b/wolfssl/ssl.h @@ -1691,6 +1691,7 @@ WOLFSSL_API const char* wolfSSL_SESSION_CIPHER_get_name(const WOLFSSL_SESSION* WOLFSSL_API const char* wolfSSL_get_cipher(WOLFSSL* ssl); WOLFSSL_API void wolfSSL_sk_CIPHER_free(WOLF_STACK_OF(WOLFSSL_CIPHER)* sk); WOLFSSL_API WOLFSSL_SESSION* wolfSSL_get1_session(WOLFSSL* ssl); +WOLFSSL_API int wolfSSLSessionIsSetup(WOLFSSL_SESSION* session); WOLFSSL_API WOLFSSL_X509* wolfSSL_X509_new(void); WOLFSSL_API WOLFSSL_X509* wolfSSL_X509_new_ex(void* heap); From b184cdf7b5affec6a0bd8e5a02b925f15386a3d2 Mon Sep 17 00:00:00 2001 From: John Bland Date: Tue, 16 Apr 2024 13:26:01 -0400 Subject: [PATCH 2/3] add underscore to make it more consistient and readable --- tests/api.c | 2 +- wolfssl/ssl.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/api.c b/tests/api.c index bc94b5dc9..9f5a8c46c 100644 --- a/tests/api.c +++ b/tests/api.c @@ -47152,7 +47152,7 @@ static int test_wolfSSL_SESSION(void) ExpectPtrNE((sess = wolfSSL_get1_session(ssl)), NULL); /* ref count 1 */ ExpectPtrNE((sess_copy = wolfSSL_get1_session(ssl)), NULL); /* ref count 2 */ - ExpectIntEQ(wolfSSLSessionIsSetup(sess), 1); + ExpectIntEQ(wolfSSL_SessionIsSetup(sess), 1); #ifdef HAVE_EXT_CACHE ExpectPtrEq(sess, sess_copy); /* they should be the same pointer but without * HAVE_EXT_CACHE we get new objects each time */ diff --git a/wolfssl/ssl.h b/wolfssl/ssl.h index 5c097fb7f..d0e4058d0 100644 --- a/wolfssl/ssl.h +++ b/wolfssl/ssl.h @@ -1691,7 +1691,7 @@ WOLFSSL_API const char* wolfSSL_SESSION_CIPHER_get_name(const WOLFSSL_SESSION* WOLFSSL_API const char* wolfSSL_get_cipher(WOLFSSL* ssl); WOLFSSL_API void wolfSSL_sk_CIPHER_free(WOLF_STACK_OF(WOLFSSL_CIPHER)* sk); WOLFSSL_API WOLFSSL_SESSION* wolfSSL_get1_session(WOLFSSL* ssl); -WOLFSSL_API int wolfSSLSessionIsSetup(WOLFSSL_SESSION* session); +WOLFSSL_API int wolfSSL_SessionIsSetup(WOLFSSL_SESSION* session); WOLFSSL_API WOLFSSL_X509* wolfSSL_X509_new(void); WOLFSSL_API WOLFSSL_X509* wolfSSL_X509_new_ex(void* heap); From 804cf1c3b727a075eb338a8ea64e28aa9e5c2e9c Mon Sep 17 00:00:00 2001 From: John Bland Date: Wed, 17 Apr 2024 04:04:00 -0400 Subject: [PATCH 3/3] re-add function to new file --- src/ssl_sess.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ssl_sess.c b/src/ssl_sess.c index 4a2b1f7c2..5362d177d 100644 --- a/src/ssl_sess.c +++ b/src/ssl_sess.c @@ -283,6 +283,13 @@ WOLFSSL_SESSION* wolfSSL_get1_session(WOLFSSL* ssl) return sess; } +/* session is a private struct, return if it is setup or not */ +WOLFSSL_API int wolfSSL_SessionIsSetup(WOLFSSL_SESSION* session) +{ + if (session != NULL) + return session->isSetup; + return 0; +} /* * Sets the session object to use when establishing a TLS/SSL session using