Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 5 additions & 3 deletions doc/dox_comments/header_files/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11971,11 +11971,13 @@ int wolfSSL_CTX_UseSessionTicket(WOLFSSL_CTX* ctx);
\ingroup IO

\brief This function copies the ticket member of the Session structure to
the buffer.
the buffer. If buf is NULL and bufSz is non-NULL, bufSz will be set to the
ticket length.

\return SSL_SUCCESS returned if the function executed without error.
\return BAD_FUNC_ARG returned if one of the arguments was NULL or if the
bufSz argument was 0.
\return BAD_FUNC_ARG returned if ssl or bufSz is NULL, or if bufSz
is non-NULL and buf is NULL


\param ssl a pointer to a WOLFSSL structure, created using wolfSSL_new().
\param buf a byte pointer representing the memory buffer.
Expand Down
10 changes: 9 additions & 1 deletion src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4292,7 +4292,15 @@ int wolfSSL_CTX_UseSessionTicket(WOLFSSL_CTX* ctx)

int wolfSSL_get_SessionTicket(WOLFSSL* ssl, byte* buf, word32* bufSz)
{
if (ssl == NULL || buf == NULL || bufSz == NULL || *bufSz == 0)
if (ssl == NULL || bufSz == NULL)
return BAD_FUNC_ARG;

if (*bufSz == 0 && buf == NULL) {
*bufSz = ssl->session->ticketLen;
return LENGTH_ONLY_E;
}

if (buf == NULL)
return BAD_FUNC_ARG;

if (ssl->session->ticketLen <= *bufSz) {
Expand Down
5 changes: 5 additions & 0 deletions tests/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -27863,13 +27863,18 @@ static int test_wolfSSL_SESSION(void)
const char* ticket = "This is a session ticket";
char buf[64] = {0};
word32 bufSz = (word32)sizeof(buf);
word32 retSz = 0;

ExpectIntEQ(WOLFSSL_SUCCESS,
wolfSSL_set_SessionTicket(ssl, (byte *)ticket,
(word32)XSTRLEN(ticket)));
ExpectIntEQ(WOLFSSL_SUCCESS,
wolfSSL_get_SessionTicket(ssl, (byte *)buf, &bufSz));
ExpectStrEQ(ticket, buf);

/* return ticket length if buffer parameter is null */
wolfSSL_get_SessionTicket(ssl, NULL, &retSz);
ExpectIntEQ(bufSz, retSz);
}
#endif

Expand Down
Loading