Repository navigation
feat: add Client::duplicate - #325
larseggert wants to merge 11 commits into
Conversation
Two tests fail until NSS ships the fix for bug 2086988.
It creates a new client with the same TLS configuration and no handshake state, e.g. to restart after Version Negotiation.
Merging this PR will not alter performance1 warning
Comparing |
|
https://bugzilla.mozilla.org/show_bug.cgi?id=2086988 TLS part is landed, I kept the bug opened in order to address the DTLS part |
| /// # Errors | ||
| /// | ||
| /// Errors returned if the client was closed, or if the socket can't be created or configured. | ||
| pub fn duplicate(&self) -> Res<Self> { |
There was a problem hiding this comment.
I am curious if you'd benefit from smth like
#define SSL_ResetCallbacks(fd) \
SSL_EXPERIMENTAL_API("SSL_ResetCallbacks", \
(PRFileDesc * _fd), (fd))
There was a problem hiding this comment.
Ah but it could be used only for a duplication, so we can just implement a SSL_ImportFDConfig (or give it a better name)
There was a problem hiding this comment.
Something in this shape:
static void
ssl_ResetAppCallbacks(sslSocket *ss)
{
ss->alertReceivedCallback = NULL;
ss->alertReceivedCallbackArg = NULL;
{...}
}
SECStatus
SSLExp_ImportFDConfig(PRFileDesc *model, PRFileDesc *fd, PRFileDesc **out)
{
sslSocket *ms = ssl_FindSocket(model);
PRFileDesc *imported = ssl_ImportFD(model, fd, ms->protocolVariant);
ResetAppCallbacks(imported);
out = imported;
return SECSuccess;
}
There was a problem hiding this comment.
There was a problem hiding this comment.
I don't think so?
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #325 +/- ##
==========================================
+ Coverage 75.89% 76.45% +0.56%
==========================================
Files 28 28
Lines 3423 3479 +56
Branches 3423 3479 +56
==========================================
+ Hits 2598 2660 +62
+ Misses 608 599 -9
- Partials 217 220 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because the tests do not verify that a duplicate completes its handshake and receives both secrets after the original is dropped with callbacks already installed.
2 open issues
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
Human verification is needed to confirm the minimum supported NSS 3.134 includes the bug 2086988 fix and validate cloned callback lifetimes across handshake modes and drop orders.
No open issues 🎉
2 resolved since last review
Review effort: Balanced


Adds
Client::duplicate(), which usesSSL_ImportFDto create a new client with the same TLS configuration and no handshake state, e.g. for restarting a connection after Version Negotiation. The duplicate rebinds the callbacks and extension handlers NSS copies, and starts without resumption tokens. Requires the NSS fix for bug 2086988.