Skip to content

Conversation

@julek-wolfssl
Copy link
Member

@julek-wolfssl julek-wolfssl commented Oct 29, 2025

Introduces client and server examples that demonstrate the use of
TLS 1.3 early data (0-RTT) with session resumption.

The client example performs an initial handshake to obtain a session
ticket, then reconnects and sends early data. The server example
receives early data and sends back a reply.

DTLS 1.3 examples depend on wolfSSL/wolfssl#9367

Introduces client and server examples that demonstrate the use of
TLS 1.3 early data (0-RTT) with session resumption.

The client example performs an initial handshake to obtain a session
ticket, then reconnects and sends early data. The server example
receives early data and sends back a reply.
/* Check if ticket was received */
if (!wolfSSL_SessionIsSetup(wolfSSL_SSL_get0_session(ssl))) {
/* Attempt to read a session ticket from server */
(void)wolfSSL_read(ssl, recvBuf, sizeof(recvBuf)-1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why -1 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For null termination

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we receive data here then data is never use, probably it's better to to check and print

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is outdated. Its using wolfSSL_peek now.

@julek-wolfssl julek-wolfssl requested a review from rizlik November 7, 2025 10:25
/* Check if ticket was received */
if (!wolfSSL_SessionIsSetup(wolfSSL_SSL_get0_session(ssl))) {
/* Attempt to read a session ticket from server */
(void)wolfSSL_read(ssl, recvBuf, sizeof(recvBuf)-1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we receive data here then data is never use, probably it's better to to check and print

@rizlik rizlik assigned julek-wolfssl and unassigned rizlik Nov 7, 2025
@julek-wolfssl julek-wolfssl requested a review from rizlik November 7, 2025 12:58
@julek-wolfssl julek-wolfssl assigned rizlik and unassigned julek-wolfssl Nov 7, 2025
}

/* === 1st connection: perform handshake and get session ticket === */
sockfd = udp_connect(server_ip, DEFAULT_PORT, &servAddr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you rename in udp_create_socket?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

sockfd = -1;

/* === 2nd connection: resume session and send early data === */
sockfd = udp_connect(server_ip, DEFAULT_PORT, &servAddr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

During the resumed (second) DTLS connection, read any server data that
arrives during the handshake and print it. This adds a memset and
wolfSSL_read into recvBuf and prints when len > 0.
@julek-wolfssl julek-wolfssl requested a review from rizlik November 21, 2025 12:56
printf("Server sent during handshake: %s\n", recvBuf);
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is cleaner to keep calling wolfSSL_connect after reading server 1-RTT data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants