-
Notifications
You must be signed in to change notification settings - Fork 190
Add TLS 1.3 early data examples #530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
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.
tls/client-tls13-earlydata.c
Outdated
| /* 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why -1 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For null termination
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
tls/client-tls13-earlydata.c
Outdated
| /* 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); |
There was a problem hiding this comment.
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
dtls/client-dtls13-earlydata.c
Outdated
| } | ||
|
|
||
| /* === 1st connection: perform handshake and get session ticket === */ | ||
| sockfd = udp_connect(server_ip, DEFAULT_PORT, &servAddr); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
dtls/client-dtls13-earlydata.c
Outdated
| sockfd = -1; | ||
|
|
||
| /* === 2nd connection: resume session and send early data === */ | ||
| sockfd = udp_connect(server_ip, DEFAULT_PORT, &servAddr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
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.
| printf("Server sent during handshake: %s\n", recvBuf); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
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
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