Skip to content

Commit 2285d4d

Browse files
liveansCopilot
andcommitted
Assert empty payload before discarding it on CertValidationNeeded
VerifyRemoteCertificateAndGenerateNextToken released the incoming token's payload unconditionally. SecureTransport pauses the handshake at the peer- auth-completed break before producing the next flight, so the pending- writes buffer drained into the token is expected to be empty. Add a debug assert so any future regression that produced bytes at this point is surfaced loudly instead of silently dropping handshake bytes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5b44015 commit 2285d4d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Protocol.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,11 @@ private ProtocolToken GenerateToken(ReadOnlySpan<byte> inputBuffer, out int cons
944944
#if TARGET_APPLE
945945
private ProtocolToken VerifyRemoteCertificateAndGenerateNextToken(ProtocolToken token)
946946
{
947+
// SecureTransport pauses the handshake (errSSL{Server,Client}AuthCompleted) before
948+
// any bytes are produced for the next handshake flight, so the pending-writes buffer
949+
// drained into token should be empty here. Assert to catch any future regression
950+
// that would silently drop handshake bytes.
951+
Debug.Assert(token.Size == 0, "Expected empty payload at CertValidationNeeded pause; dropping non-empty payload would lose handshake bytes.");
947952
token.ReleasePayload();
948953

949954
ProtocolToken alertToken = default;

0 commit comments

Comments
 (0)