Repository navigation
fix: fail handshake() when the peer certificate is rejected - #174
Merged
Merged
Conversation
uwezkhan
requested review from
Not-Nik,
beurdouche,
jschanck,
larseggert and
martinthomson
as code owners
August 28, 2026 15:35
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #174 +/- ##
==========================================
+ Coverage 72.30% 72.53% +0.22%
==========================================
Files 28 28
Lines 3405 3411 +6
Branches 3405 3411 +6
==========================================
+ Hits 2462 2474 +12
+ Misses 726 723 -3
+ Partials 217 214 -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:
|
martinthomson
approved these changes
Aug 28, 2026
martinthomson
left a comment
Member
There was a problem hiding this comment.
This is good. The CI failures need attention from other angles, so don't worry too much about them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the application rejects a peer certificate by passing a non-zero status to
authenticated(), the nexthandshake()call runsSSL_AuthCertificateComplete(fd, err)and uses its return value for the state transition. NSS returnsSECSuccessfrom that call even whenerrrejects the certificate, so the client moves toCompleteandis_connected()becomes true while a fatal certificate alert has already been queued.handshake_rawdoes not have this problem because it always drivesSSL_ForceHandshakeafterward and transitions on that instead.On the rejected path the fix now forces the handshake after
SSL_AuthCertificateCompleteand transitions on that result, which fails as expected. The accepted path (err == 0) still transitions on theSSL_AuthCertificateCompletereturn, so a valid handshake completes in a single call and only the rejection path gains the extraSSL_ForceHandshake. The added regression test rejects the certificate and asserts thathandshake()returns an error with the agent inFailedrather than connected.